Hi guys. I have an assignment and am having trouble making the functions, pointers, and character strings/arrays work together.
I have to use fgets() to take an input, then split it into the individual words/phrases that are typed and ignore excess spaces etc.
for example, a valid input could be:
i input.txt o output.txt p password k 2392
but an equally valid input could be
i input.txt o output.txt k 2392
im getting a lot of errors that dislike me using char* when it wants normal char and vice versa. code is below. thanks!!!
Code:--------main function ------------- void main() { int x=0; int inp_out; char main_input[1000]; char* string; char v1; char *value; printf("please enter files to be encrypted: "); fgets(main_input, sizeof(main_input), stdin); printf("\n\nmain_input = %s\n\n", main_input); get_next_value(*main_input); v1 = *value; get_next_value(*string); v2 = *value get_next_value(*string); v2 = *value get_next_value(*string); v2 = *value return 0; } ------- function get_next_input----------- char get_next_input(char s[]) { char value; int i; int v =0; char* string; for(i=0;i<strlen(s);i++) { if(isalpha(s[i])) { value[v] = s[i]; v++; if(isspace(s[i+1])) { string = &s[i+1]; return value; } } } }



LinkBack URL
About LinkBacks





