I am new in C i am create a program which will read input parameter from command line and then it will do the comparison, but when i am trying to compile the code i am getting error "warning: initialization makes integer from pointer without a cast" .
I found many example on stack overflow for this error but i am unable to relate the issue in my code . Below is the sample code :
void validateGuess(int guess) {
if (guess < 555) {
printf("Your guess is too low.");
} else if (guess > 555) {
printf("Your guess is too high.");
} else {
printf("Correct. You guessed it!");
}
}
int main(int argc, int** argv) {
int arg1 = argv[0];
validateGuess(arg1);
}
Below error i am getting :
test.c: In function ‘main’:
test.c:14: warning: initialization makes integer from pointer without a cast
argv[0]is not anint. It is a string pointer to the executable file name. The first user argument isargv[1]but that too is a string pointer. You need to convert that textual input into an integer variable.