c - main not recognizing my function -


#include <stdio.h> #include <stdlib.h>  void reverse(char* lines[], int count) {     (int = count-1; >= 0; i--)     {             printf("%s", lines[i]);     } } 

.

#include <stdio.h> #include <string.h> #include <stdlib.h> #include "sortutil.h" #include "reverse.h"   int getarray(char *lines[]); void printarray(char *lines[], int max);  int main(int argc, char* argv[]) {     char* arr[100];     int numlines = getarray(arr);     printf("there %d lines\n", numlines);     printarray(arr, numlines);       (int = 1; < argc;  i++)     {             if (strcmp(argv[i], "-s") == 0)             {                     sortutil(arr);                     printarray(arr, numlines);             }             if (strcmp(argv[i], "-r") == 0)             {                     reverse(arr, numlines);                     printarray(arr, numlines);             }      } }  int getarray(char *lines[]) {     int = 0;     char *text = (char *)malloc(200);     while (fgets(text, 200, stdin) != null)     {         lines[i] = text;         i++;         text = (char *)malloc(200);     }     return i; }  void printarray(char *lines[], int max) {     (int = 0; < max; i++)     {         printf("%s\n\n", lines[i]);     } } 

when compile main function telling me there undefined reference 'reverse'. did #include "reverse.h" shouldn't have problem seeing reverse function. missing something

you're missing implementation. defined prototype, function body missing. in separate file, , need tell linker it. when compile main.cc - add other file command line well.


Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -