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.

  1. how solve warning if don't want use stringfiveds in function.
  2. how make accessible in other functions can use in other function create.

i'm new this, can please detailed possible.

  1. if don't want use stringfiveds in function, can delete variable declaration because don't need it.

  2. 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

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -