Apologies for poor formatting, stil getting used to this. I aparently need meta stack exchange...
#include <stdio.h>
#include <cs50.h>
#include <ctype.h>
#include <string.h>
int main (void)
{
int n;
int i=0;
printf("Enter your name:\n");
string name = get_string(); //get name to extract initials from
n=strlen(name);
while (i<n) //Loop while position is less than name string length
{
if(isalpha(name[i]) && isspace(name[i-1])); //Print Character in uppercase if itis a lettter and there was a space in the spot before (aka first letter of name)
{
printf("%s", toupper(name[i]));
}
printf("\n");
i++;
}
}
This gives me the following compile error:
clang -fsanitize=integer -fsanitize=undefined -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wshadow initials.c -lcrypt -lcs50 -lm -o initials
initials.c:18:23: error: format specifies type 'char *' but the argument has type 'int' [-Werror,-Wformat]
printf("%s", toupper(name[i]));
~~ ^~~~~~~~~~~~~~~~
%d