I'm doing the CS50 course in C and am working on the problem set from week 2. I'm an absolute beginner so there's probably a lot wrong with my code. For now, I'm trying to create a function that checks if the user has correctly used the command line input and if that input consists of only integers.
this is my code:
#include <cs50.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
bool only_digits(string s);
int main(int argc, string argv[])
{
if (argc == 2 & only_digits > 0)
{
printf("test\n");
}
else
{
printf("usage: ./caesar key\n");
}
}
bool only_digits(string s)
{
for (int i = 0, n = strlen(s); i < n; i++)
{
if (isdigit(i))
{
return 0;
}
else
{
return 1;
}
}
}
This is the error:
caesar/ $ make caesar
caesar.c:34:1: error: non-void function does not return a value in all control paths [-Werror,-Wreturn-type]
}
^
1 error generated.
Thanks in advance, and excuse me for the many mistakes there probably are in the code. make: *** [: caesar] Error 1