Storing tokenized strings into different variables
Hi there guys, i'm relatively new to C and have a bit of a dilemma.
So far in my program i have used strtok() to tokenize the buffer of which is used to process data within a simple input file. The input file has a basic layout of such:
Processid[space]Qaunta[space]Priority[newline]:
Process0 56 1
Process1 189 23
Process 2 1 942
Once I have extracted these strings i can go on to processing them in my process scheduler. Oh and another note, I am only using core system functions of the C standard, so please no fputs, fgets, fopen etc...
Many thanks for any available advice :)
Code:
{
for ( i = 0; i < status; i++)
{
if (buffer[i] == '\n')
{
memcpy(tmpbuff, buffer,BUFFSIZE);
}
}
} else { eof = 1;
}
/* Tokenize 'process string' attributes */
procstr = strtok(tmpbuff,space);
while ( procstr != NULL ) {
proc[i].id = procstr;
procstr = strtok( NULL, space);
printf("%s\n", proc[i].id);
}