Skip to main content
GameDev.net gamedev.net
🔒 Locked

scanfing multiple words

Started by Dwiel Jun 18, 2002 at 8:31 AM 0 replies 300+ views
Original Post
Dwiel
Dwiel
hey! I have been programming for quite awhile and I have never come across this problem dont know y I cant figure it out but here she goes: I want to input a command which can consist anywhere from 1 to 64 words. when I use the code
      

//happens somewhere else

char *inp;
inp = new char[256];

//my problematic code

void GetCommand()
{
	printf(">");
	scanf("%s\n", inp);
};
    
inp ends up only containg the first word No clue y this is so hard.... thanx for the help ahead Dwiel ~ tazzel3d [edited by - tazzel3d on June 18, 2002 9:32:52 AM]
Dwiel
Dwiel
AH im stupid.. anyway i figured it out and might as well leave it on here for future ref....

new code contains the line

gets(inp);

instead of

scanf("%s\n", inp);

sorry bout that guys

dwiel ~ Tazzel3d

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.