简体   繁体   中英

expected ‘const char * __restrict__’ but argument is of type ‘int’ with strtok function

char *local_buffer, *buff;
fgets(buff, 1024, fp);

local_buffer=strtok(buff,'\t'); //Error is coming with this line

I have already tried passing a character variable instead of '\\t', but still its showing the same error.

You're passing in a character constant (which is equivalent to an integer), not a string, for the second argument.

local_buffer=strtok(buff,'\t');

What you want instead is:

local_buffer=strtok(buff,"\t");

Try:

char *local_buffer, buff[1024];
fgets(buff, 1024, fp);

local_buffer=strtok(buff,"\t"); //Error is coming with this line

Explanation:

Double quotes ("") around characters represent a null-terminated C-style character string ( char* )

Single quotes ('') around a character represents a character (apparently int )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM