Archived

This topic is now archived and is closed to further replies.

Pinguino

What the hell!!??

Recommended Posts

Pinguino    122
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.

Share this post


Link to post
Share on other sites
sSimontis    100
#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

Share this post


Link to post
Share on other sites
UltimaX    468
#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]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
; 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.


Share this post


Link to post
Share on other sites
UltimaX    468
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]

Share this post


Link to post
Share on other sites
Pinguino    122
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.

Share this post


Link to post
Share on other sites
FiZZLe    122
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]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest 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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
UltimaX    468
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.


Erm, no. I just tried it agian and no error. As a matter of fact, I was trying to get the error your talking about and I couldn't. I even tried 'scanf("________________%s", username);' and no error. It stilled returned the right name to

EDIT:
Ignore the '_', it took out the spaces.

-UltimaX-

"You wished for a white christmas... Now go shovel your wishes!"

[edited by - UltimaX on September 2, 2003 7:07:15 PM]

Share this post


Link to post
Share on other sites