C - warning: unused variable -
i have following code below in function.
char * stringfiveds = strtok(stringfive[3], "ds"); when compile warning unused variable.
i don't plan on using srtingfiveds in function. want use in main(). have 2 parts question.
- how solve warning if don't want use
stringfivedsin function. - how make accessible in other functions can use in other function create.
i'm new this, can please detailed possible.
if don't want use
stringfivedsin function, can delete variable declaration because don't need it.if want make accessible other functions, can declare global variable, or pass argument other functions.
so instead of
char * stringfiveds = strtok(stringfive[3], "ds"); you can have just
strtok(stringfive[3], "ds"); if want declare stringfiveds global variable, declare outside of function:
#include <stdio.h> char * stringfiveds; // declare outside of function void foo() { // can access stringfiveds here } int main() { // can access stringfiveds here } if want pass stringfiveds function argument:
#include <stdio.h> // declare outside of function void foo(char * stringfiveds) { } int main() { char * stringfiveds; foo(stringfiveds); }
Comments
Post a Comment