This my code for the pset problem Initials and it works correctly.
/*a program that prompts a user for their name (using GetString to obtain their name as a string)
and then outputs their initials in uppercase with no spaces or periods, followed by a newline*/
#include <stdio.h>
#include <cs50.h>
#include <ctype.h>
#include <string.h>
int main(int argc, string argv[])
{
for(int i = 0; i < argc; i++)
{
int j, n;
//prints initials in capital letters
for(j = 0, n = strlen(argv[i]); j < n; j++)
printf("%c", toupper((char) argv[j][0]));
}
printf("\n");
}
it compiles the initials,but its always followed by a segmentation fault.
~/workspace/pset2/ $ make initial1
clang -ggdb3 -O0 -std=c11 -Wall -Werror -Wshadow initial1.c -lcs50 -lm -o initial1
~/workspace/pset2/ $ ./initial1 olarinde ayodeji
.OASegmentation fault
~/workspace/pset2/ $
Any reason for the segmentation fault?