I would appreciate any help that could be given with my code below (+ error codes below that):
My code will not compile and the primary error apparently is an "undeclared identifier" refering to argv. however i believe i have identified the string array in the initial line (int main argc string argv[MaxprobaleInput])
Any other flaws in my code that anyone can see would also be greatly appreciated.
#include <cs50.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
//DECLARE VARIABLES TO BE USED IN CODE GLOBALLY
int MaxProbableInput = 12;
int MinimumProgInput = 2;
int IterateUserInput = 0;
int UserInputCharCount = strlen(argv);
int main(int argc, string argv [MaxProbableInput])
{
//MAKE SURE THE USER INPUTS A NAME AT COMMAND LINE
if (argc <= MinimumProgInput)
{
printf("The proramme requires your full name to execute. e.g: ./initials Chengetai Chiwanga\n");
return 1;
}
//PRINT THE FIRST LETTER OF THE USER INPUT IN CAPS
if (argv[0] != ' ' && argv[0] != NULL)
{
printf("%c,toupper argv [0][1]);
}
//PRINT CONCURRENT INITIALS OF THE USERS INPUT IN CAPS
for (IterateUserInput; IterateUserInput < UserInputCharCount; IterateUserInput++)
if (UserInputCharCount == ' ' && UserInputCharCount [IterateUserInput + 1] != NULL)
{
printf("%c", topupper argv[IterateUserInput + 1] );
return 0;
}
}
}
Error codes:
clang -fsanitize=signed-integer-overflow -fsanitize=undefined -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wshadow initials.c -lcrypt -lcs50 -lm -o initials
initials.c:11:33: error: use of undeclared identifier 'argv'
int UserInputCharCount = strlen(argv);
^
initials.c:26:22: error: comparison between pointer and integer ('string'
(aka 'char *') and 'int') [-Werror]
if (argv[0] != ' ' && argv[0] != NULL)
~~~~~~~ ^ ~~~
initials.c:30:33: error: expected ')'
printf("%c",toupper argv [0][1]);
^
initials.c:30:19: note: to match this '('
printf("%c",toupper argv [0][1]);
^
initials.c:38:69: error: subscripted value is not an array, pointer, or vector
if (UserInputCharCount == ' ' && UserInputCharCount [IterateUserInput + 1] != NULL)
~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~
initials.c:41:38: error: expected ')'
printf("%c", toupper argv[IterateUserInput + 1] );
^
initials.c:41:23: note: to match this '('
printf("%c", toupper argv[IterateUserInput + 1] );
^
initials.c:36:22: error: expression result unused [-Werror,-Wunused-value]
for (IterateUserInput; IterateUserInput < UserInputCharCount; IterateUserInput++)
^~~~~~~~~~~~~~~~
6 errors generated.
make: *** [initials] Error 1
Thanks in advance.
PotNoodle