New to C. I do realize that there are threads about this problem everywhere, but I've searched through at least half of them and haven't yet found one that properly applied to this situation.
I get the warning "passing arg 1 of `strcpy' makes pointer from integer without a cast". I know what this means but I don't know how to fix it in this case.
Next part, I want to compare a value to NULL. I would just like to ask if this would be the same thing as comparing to zero.Code:/* Declare variables */ char command[50][10]; /* Array to store commands into */ int i, j, k, l, m = 0; /* Counter variables for command storage */ int main( void ) { /* Declare variables */ FILE *file; /* File used for reading */ char *tokenPtr; /* Current word being read */ char fileName[6]; /* File name */ /* Arrays */ char line[80][50]; /* Array to store line in the file */ /* Iterate through the lines array */ for( j = 0; j < i; j++ ) { /* Tokenize line with a space, new line, and tab delimiter */ tokenPtr = strtok( line[j], " \n\t" ); /* Convert tokenized into upper case */ *tokenPtr = toupper( *tokenPtr ); /* As long as there are still more words to be read */ while( tokenPtr != NULL ) { /* Copy the line's words into the command array */ strcpy( command[j][k], tokenPtr ); /* Increment counter for second index */ k++; /* Get next token */ tokenPtr = strtok( NULL, " \n\t" ); } k = 0; } }
Thanks for any help!Code:/* Determine error type and print out corresponding error message */ if( command[m][1] < 0 ) { printf( "\nError: Parameter cannot have a value under 1.", command[m][0] ); } else if( command[m][1] == 0 ) { printf( "\nError: Command %s takes in an int parameter.", command[m][0] ); }



LinkBack URL
About LinkBacks



