Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

2
pset2 initials
Post Body

hi, my initials program is failing the cs50 check even when the output is the correct one, I know my code is not probably the best solution, but it works. Thanks in advance for any help.

int main (void) {

string userName;

printf("Write your full name:\n");

userName = get_string();
char space = ' ';


if (userName != NULL) {

    printf("%c", toupper(userName[0]));

    for (int i =1, length = strlen(userName); i < length ; i  ) {


        if ( userName[i] == space) {

            printf ("%c",toupper(userName[i 1]));

        }
    }
    printf("\n");
}

}

this is the result of the cs50 check:

:) initials.c exists :) initials.c compiles :( outputs "MB" for "Milo Banana" \ expected prompt for input, not output of "Write your full name:\n" :( outputs "MB" for "milo banana" \ expected prompt for input, not output of "Write your full name:\n" :( outputs "RTB" for "Robert Thomas Bowden" \ expected prompt for input, not output of "Write your full name:\n" :( outputs "R" for "ROB" \ expected prompt for input, not output of "Write your full name:\n" :( outputs "RTB" for "Robert thomas Bowden" \ expected prompt for input, not output of "Write your full name:\n"

Author
Account Strength
90%
Account Age
7 years
Verified Email
Yes
Verified Flair
No
Total Karma
3,425
Link Karma
83
Comment Karma
3,324
Profile updated: 5 days ago
Posts updated: 1 month ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
7 years ago