What the hell!!??
Every time I write a program I get tons of errors, even if the program is really short I get errors saying I am making syntax errors and stuff like parse errors which I don''t even know what that means!!
Here''s the source code, I am usind DevC++ 4 and I am writing in C:
#include <stdio.h>
#include <stdlib.h>
main()
{
char username[10]
printf("Hi what''s you''re name?\n")
scanf(" %s", username);
printf("Well Hi %s, I''m your computer!!!\n", username);
getchar()
return 0;
}
I''ll really appreciate it if somebody can help me out with this, I''m too confused. Thanks in advance.
#include <cstdlib>
#include <cstdio>
using namespace std;
That should work, but you are using C. I reccomend using Dev-C++ 5.
Scott Simontis
e-mail:ageofscott@comcast.net
AIM:ssimontis
#include <cstdio>
using namespace std;
That should work, but you are using C. I reccomend using Dev-C++ 5.
Scott Simontis
e-mail:ageofscott@comcast.net
AIM:ssimontis
#include <stdio.h>
#include <stdlib.h>
int main()
{
char username[10];
printf("Hi what's you're name?\n");
scanf(" %s", username);
printf("Well Hi %s, I'm your computer!!!\n", username);
return 0;
}
Does that help?
EDIT:
Beat me by 4 seconds
-UltimaX-
"You wished for a white christmas... Now go shovel your wishes!"
[edited by - UltimaX on September 1, 2003 8:04:46 PM]
#include <stdlib.h>
int main()
{
char username[10];
printf("Hi what's you're name?\n");
scanf(" %s", username);
printf("Well Hi %s, I'm your computer!!!\n", username);
return 0;
}
Does that help?
EDIT:
Beat me by 4 seconds
-UltimaX-
"You wished for a white christmas... Now go shovel your wishes!"
[edited by - UltimaX on September 1, 2003 8:04:46 PM]
; after these lines:
char username[10];
printf("Hi what''s you''re name?\n";
.
.
.
getchar();
also that getchar would not work...check for required input vars.
char username[10];
printf("Hi what''s you''re name?\n";
.
.
.
getchar();
also that getchar would not work...check for required input vars.
quote:Original post by sSimontis
#include <cstdlib>
#include <cstdio>
using namespace std;
That should work, but you are using C. I reccomend using Dev-C++ 5.
Scott Simontis
e-mail:ageofscott@comcast.net
AIM:ssimontis
Actually, I tested it and you don't need 'using namespace std'. It should work fine after you add your semi-colons and take out the getchar(). You wont get an error from getchar(), but it's just not needed.
-UltimaX-
"You wished for a white christmas... Now go shovel your wishes!"
[edited by - UltimaX on September 1, 2003 8:08:05 PM]
Thank you very much, I really appreciate the help. It works now, I keep on forgetting the ; after my statements, I think I finally got it now, and again thanks.
quote:Original post by sSimontis
...I reccomend using Dev-C++ 5...
Scott Simontis
e-mail:ageofscott@comcast.net
AIM:ssimontis
Is it already released? I have version 4.9.8.0 and I don't know if 5.0 is already released...
----->FiZZLe<-----
"A game is like christmas, you'll never know what you're gonna get"
[edited by - FiZZLe on September 2, 2003 11:33:57 AM]
You are using:
scanf(" %s", username);
Omit the space before the %. This will give you:
scanf("%s",username);
With your code, the user must enter a space key and only then does the computer read in the user name. If you do not type in a space, it will give you an error.
scanf(" %s", username);
Omit the space before the %. This will give you:
scanf("%s",username);
With your code, the user must enter a space key and only then does the computer read in the user name. If you do not type in a space, it will give you an error.
quote:Original post by Anonymous Poster
You are using:
scanf(" %s", username);
Omit the space before the %. This will give you:
scanf("%s",username);
With your code, the user must enter a space key and only then does the computer read in the user name. If you do not type in a space, it will give you an error.
uhh... no.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement