This forum is in archive mode. You will not be able to post new content.

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - xMoD

Pages: [1]
1
Anyone at all, have anything.
I tried on another forum, but didnt get anything at all either!

2

For the junk code, try this.
declare fin as
Code: [Select]
char fin[100]={0};


didnt change at all :/


Doesnt anyone know how to do what I need :/

take string from cin split by comma into char array
At least without using boost

3
C - C++ / I need to take string from cin, split by comma into char array
« on: November 01, 2014, 08:35:57 PM »
Code: [Select]

char *split(string s)
{
char holder[100]; // Holder for string to char[]
char fin[100];   // Final array
char * pch;


strcpy(holder, s.c_str());


pch = strtok(holder, " ");
while (pch != NULL)
{
printf("=>%s\n", pch);
strcpy(fin, pch); // copy pch into fin array
pch = strtok(NULL, " ");
}
return fin;
}


Is my current code, and I use like:


string cmd;
getline(cin,cmd);
cout << split(cmd)<<endl;


It spits out each thing i type on a new line, seperated by a space...
But when I cout it, its a jumble of junk :



Is there a better way to do this, and where if i did
split(cmd)[0] the first element would be the first word separated by a space OR comma.. (Or any other deliminator i want)
Thanks :D

Pages: [1]


Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.