Hi All,
I am facing a problem with using the function strtok(). Following is just a sample code.
The code below stores the string str delimited by comma into an array.
I want to modify the code below so that array would contain an empty space/new line if a value is missing.
i.e., if str[] = source, desti, string1,,string3 ; then my array should hold an empty space/ new line in place of string2.
Can somebody help me with this?
Thanks in Advance
#include <stdio.h>
#include <conio.h>
#include <string.h>
main()
{
char str[] = "source,desti,string1,string2,string3";
char delims[] = ",";
char *result = NULL;
char myArray[10][50],*p;
result = strtok( str, delims );
while( result != NULL )
{
printf( "%s \n", result );
result = strtok( NULL, delims );
}
getch();
}