please dont laugh at me as i am totally new to programming, and on top of that maybe not very smart. I am just enjoying a lot what i am learning though i am afraid i will not be able to finish the cs50 course cause it seems to hard. Anyway, im trying to solve the initials pset2. I can get first letter of first word in printed in capital, and thats it. I can t find the logic to go to next word. At the beginning i was going with argv and argc so at least i could isolate names and get to first letter. But with int-main-void i just cant seem to do it. Here is my code, any hint would be much appreciated
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
int main(void)
{
//get a name
string name = get_string();
//make sure you get a word
if (name != NULL)
//print First capital Firts word
printf("%c", toupper(name[0]));
{
for
//loop duration until /0ahahah i wanna get after this \0
(int i = 0;name[i] == '\0'; i++ )
{
if(name[i] == ' ')
{
//print 0 +1 character (next after space)
printf("%c", toupper (name[i]+1));
}
}
printf("\n");
}}
after Blauelf suggestion
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
int main(void)
{
//get a name
string name = get_string();
//make sure you get a word
if (name != NULL)
//print First capital Firts word
printf("%c", toupper(name[0]));
{
for
//loop duration until /0ahahah i wanna get after this \0
(int i = 0;name[i] != '\0'; i++ )
{
if(name[i] == ' ')
{
//print 0 +1 character (next after space)
printf("%c", toupper (name[i+1]));
}
}
printf("\n");
}}
its working but i dont get why.It should stop after the first inputted word, aint it?