So, I keep getting this error:
$ gcc -Wall -g translate.c support.c scanner.c -o translate translate.c: In function 'main': translate.c:22:16: warning: assignment from incompatible pointer type [enabled by default] dictionary = createArray(count); ^ support.c: In function 'readTokens': support.c:66:18: warning: assignment from incompatible pointer type [enabled by default] a[count] = token; ^
and I do not know why.
here is my main function:
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "support.h" int main(int argc, char** argv) { int i; int count; char** dictionary; if (argc != 3) { printf("need two arguments!\n"); exit(-1); } count = countTokens(argv[1]); printf("there are %d tokens and strings\n", count); dictionary = createArray(count); readTokens(argv[1], dictionary); printf("The dictionary:\n"); for (i = 0; i < count; ++i) { printf("%s\n", dictionary[i]); } return 0; }
and my function to create arrays:
char* createArray(int count) { char* a; a = malloc(sizeof(char*) * count); if (a == 0) { fprintf(stderr, "memory allocation failed\n"); exit(1); } return a; }
and title
char * createArray(int);
I have no idea how to get this to go. I tried to take and add asterics and go from one equal sign to two, but it does not work. 2nd year student cs, first year in C. Any help would be appreciated a million times. Thanks!
source share