I am working on a code that takes the string containing the name of someone and prints the initials of that name capitalized, whenever I run my code, I keep getting the initials printed twice, which I don't know how to fix this issue and get the desired output.
Here is my code:
#include <cs50.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(void)
{
string name = GetString();
char* pointer;
pointer = strtok(name, " ");
while (pointer != NULL)
{
printf("%c", putchar(toupper(pointer[0])));
pointer = strtok (NULL, " ");
}
printf("\n");
}
when I run the code with for example: ahmed salah eldin
output:
AASSEE
I just need :
ASE