How do I duplicate the string stored in a strtok() token?

ساخت وبلاگ

Vote count: 0

I'm trying to duplicate the value of a strtok() token.

I'm running strtok() on a string with volatile value.

char buffer[100];
char temp[100];
for(int i = 0; i < 100; i++){
fgets(buffer, 100, my_file);
fscanf(my_file, "%s", temp)
}

An example value for temp in this case might be "100,200,300"

char my_array[3][3];
char* token;
token = strtok(temp,",");
while(token != NULL){
switch (token[0])
case 1 :
strcpy(my_array[0], token);
break;
case 2 :
strcpy(my_array[1], token);
break;
case 3 :
strcpy(my_array[2], token);
break;
}

What i'm attempting to do with strcpy() is to duplicate the value of the token, and store the duplicate value in an array.

asked 2 mins ago

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : how do i register to vote,how do i get home,how do i register to vote in ny,how do i get a passport,how do i get more pokeballs,how do i play pokemon go,how do i renew my passport,how do i love thee,how do i get you alone,how do i screenshot, نویسنده : استخدام کار backsoft بازدید : 367 تاريخ : شنبه 24 مهر 1395 ساعت: 0:24