|
-
Sep 20th, 2001, 07:04 PM
#1
Thread Starter
Member
Lil Help
The error in the code is is in Tokenise i think its when token doesnt = NULL it tries to put it in the array still so it crashes please help
************ code******************
#include "iostream"
#include "string"
using namespace std;
using std::string;
void Tokenise(char *istring, string *array,int size,char *seps);
int main()
{
string sarray[25];
char instring[]= "This is a String";
Tokenise(instring,sarray,25," ");
cout << sarray[0];
system("pause");
return 0;
}
void Tokenise(char *istring, string *array,int size ,char *seps)
{
/* Establish string and get the first token */
int i = 1;
char* token = NULL;
token = strtok( istring, seps );
array[0] = token;
while( token != NULL)
{
/* Get next token */
token = strtok( NULL, seps );
array[i] = token;
i++;
}
}
*********** End of Code ******************
Thanks for any help, well im off to bed ive given up till tomorrow
What is Life? One big dream or one Big nightmere.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|