c - Appending Character to String and return String -


i'm trying call in string, add character based on conditions, update longest string , return string.

i know since i'm changing string (by adding characters), can't use const char* pointer, must use char array[].

but know char array[] can't returned, pointer. i'm confused on how can update string (as char array[]), , return (as const char* pointer).

 const char* longestword(char line[])  {      int pos = 0;      char longest[250];       char ch = line[pos];      int longestlength = 0;      char current[250];      int currentlength = 0;        if(isalpha(ch) || isdigit(ch))       {           longest[longestlength] = ch;           longest[longestlength + 1] = '\0';           currentlength++;       }      pos++;    }  return longest; 

just pass array function , don't need return anything:

void longestword(char line[], char longest[])                      //       ^^^^^^^^^^^^^^ 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -