I have tried to write this out in myriad different ways but no matter what, entering any string results in the first letter being capitalized and printed ad infinitum until i kill the terminal. i have written this using different loops and altered EACH section and subsection but cannot produce a result other than this. it compiles with make.
#include <cs50.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(void)
{
string s = GetString();
if(s != NULL)
{
for(int i = 0, n = strlen(s); i < n; i++)
{
if(islower(s[i]))
{
toupper(s[i]);
}
if((i = 0) || isspace(s[i - 1]))
{
printf("%c", s[i]);
}
}
printf("\n");
}
}
NOTE: this code may not produce the correct answer for the pset, thats fine. for the moment im just trying to get it to stop spamming me one letter so i can continue to work on it.