Jump to content
  • Advertisement

Archived

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

Pinguino

What the hell!!??

This topic is 5378 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
#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
#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
; 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
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
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
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
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
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!