I feel like if I don't seek help from this forum I will end up finishing my CS50 course in 2020 :'(
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
void initials (string a);
int main (void)
{
string name = get_string ();
if (name != NULL)
{
//prints first letter in capital
printf("%c", toupper(name [0]));
//prints rest of the initials
initials (name);
printf("\n");
}
}
void initials (string a)
{
int n=0;
int l=strlen(a);
for (int i=0; i<l; i++)
{
do
{
n++;
}
while (a[n]!=32 && n<l);
printf ("%c", toupper(a[n+1]));
}
}
My initials.c programme seems to run fine when I test it but sometimes it prints an exclamation mark after the initials (What's going on?).
Also, check50 displays the following response:
:) initials.c exists :) initials.c compiles :( outputs "MB" for "Milo Banana" \ expected output, but not "MB\u0000\u0000\u0000\u0000\u0000\u0000..." :( outputs "MB" for "milo banana" \ expected output, but not "MB\u0000\u0000\u0000\u0000\u0000\u0000..." :( outputs "RTB" for "Robert Thomas Bowden" \ expected output, but not "RTB\u0000\u0000\u0000á\u000f\u0002\u000..." :( outputs "R" for "ROB" \ expected output, but not "R\u0000\u0000\u0000\n" :( outputs "RTB" for "Robert thomas Bowden" \ expected output, but not "RTB\u0000\u0000\u0000á\u000f\u0002\u000..."
I feel like my code is a mess! Help!
(Also if any of you lives in London and am happy to meet up and discuss, please let me know! Learning to code by yourself is too hard :'( )