• Advertisement

Archived

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

I need a bit of help...

This topic is 5552 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

I have this small problem here with somewhere in my code, when i run my console program instead of it letting you input more of the choices that i give you it only runs one and then it closes, #include <iostream.h> int main() { cout<<"Please input a name: "<>username; cout<<"Thank you: "<

Share this post


Link to post
Share on other sites
Advertisement
I think your code got messed up in the post, making it rather hard to see what's wrong - try reposting or editing and adding code tags around the source code,

< code > before the code
< /code > after the code



(My projects and ramblings...)

[edited by - Teodric on December 7, 2002 2:30:05 PM]

Share this post


Link to post
Share on other sites
try this:

#include <conio.h>
#include <condefs.h>
#include <iostream.h>

int main()
{
cout<<"Please input a name: "<
cin>>username;

cout<<"Thank you: "<

getch();
return 0;
}



edit: damn formatting


[edited by - evil sausage on December 7, 2002 2:24:04 PM]

[edited by - evil sausage on December 7, 2002 2:24:42 PM]

[edited by - evil sausage on December 7, 2002 2:25:25 PM]

[edited by - evil sausage on December 7, 2002 2:26:06 PM]

[edited by - evil sausage on December 7, 2002 2:26:30 PM]

Share this post


Link to post
Share on other sites
ko well i figured it all out except for the fact that now instead of showing all of what i type in, it only shows the first letter, this shit is kinda confusing now....thanks.


Into the darkness we all roam, into the light we flee from, welcome tot he land of evil and plight, wekcome to the land that i call night

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

#include <conio.h>
#include <condefs.h>
#include <iostream.h>

int main()
{
cout<<"Please input a name: "<<endl;

cin>>username;

cout<<"Thank you: "<<username;


getch();
return 0;
}


evil put your code between the [ code ] and [ / code ] tags w/o the spaces

Share this post


Link to post
Share on other sites

#include <conio.h>
#include <condefs.h>
#include <iostream.h>

int main()
{
cout<<"Please input a name: "<
cin>>username;

cout<<"Thank you: "<

getch();
return 0;
}


evil put your code between the [ code ] and [ / code ] tags w/o the spaces



shuv-it

[edited by - craphead on December 7, 2002 2:55:32 PM]

Share this post


Link to post
Share on other sites
well i seem to have figured out what was wrong, i was missing something that was needed from a header file, i found that one out, but i am still needing help with the fact that when i try to cout out a variable it will only cout the first letter, and that is all, im not sure what is wrong cause my source is all right, from what i can see, and that is from copying it from the tutorials that i have, another thing i am wondering about, would it be better to use Structs when trying to create a sorta D&D type text game rather that int and char it all out into the game

Into the darkness we all roam, into the light we flee from, welcome tot he land of evil and plight, wekcome to the land that i call night

Share this post


Link to post
Share on other sites
AAAAAAAAAHHHHHHHHH!!!!!!!!!!!!!!!!!!!!!!!!

*ahem*

You should use instead of . Just because. Really.

Share this post


Link to post
Share on other sites
Hmmmm. what kind of variable is username?

"char username" or "char username[20]"? There''s a big difference.

"char username" only stores one letter, while "char username[20]" stores nineteen letters plus a special character to let the computer know that the end of the string is reached.

You might also want to look into the standard string class, found under the header file string.h

If that isn''t your problem, then I have no idea what''s going on.

Share this post


Link to post
Share on other sites

  • Advertisement