Yah I agree, its a definate waste. I can't even figure out how to make an array of pointers to strings work.
Like:
Code:
#include <stdio.h>
#define MAX 100
#define NR_OF_STRINGS 3
main() {
char *c[NR_OF_STRINGS];
char temp[MAX];
int count;
for(count = 0; count < NR_OF_STRINGS ; count++) {
printf("Enter your %d c: ", count);
gets(temp);
printf("c[%d] = %s\n", count, temp);
c[count] = temp;
}
//c[0] = "first.";
//c[1] = "second.";
//c[2] = "third.";
for(count = 0 ; count < NR_OF_STRINGS; count++)
printf("%s\n", c[count]);
return 0;
}
This will output the last string you put in three times. However if you did:
Code:
c[0] = "first.";
c[1] = "second.";
c[2] = "third.";
it outputs fine.
heh
I know im doing something wrong but, eh, everything ive looked up thus far hasn't indicated what it is.