Here is my code

#include <stdio.h>
#include <cs50.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>

int main(int argc, string argv[]); 

  printf("Hello, what is your name?");
  string s = GetString();

for (i = 0 ; s[i] != '\0' ; ++i)
    if (i == 0 || s[i-1] == ' ')
        printf("%c", toupper(s[i]));
        printf("%c", s[i]);


First remove the semicolon from the declaration of main. You should use a semicolon at the end of a prototype of a function and not in the function itself. (If you don't know about prototypes don't worry you'll learn later about them). Secondly in your for loop you use i without declaring it first. So intead of

for (i = 0 ; s[i] != '\0' ; ++i)


for (int i = 0 ; s[i] != '\0' ; ++i)

I think that will fix your problems. As a note though keep in mind that the compiler tells you exactly where your problem is. So when I ran your code the first time it gave the following error:

init.c:9:1: error: expected identifier or '('
1 error generated.
make: *** [init] Error 1

So on line 9 there is a curly brace that it thinks shouldn't be there. If search a line above you will see the semicolon. Hope I helped and if so mark the answer as correct! Have a nice one!

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .