I started "well" this particular pset. It's about "initials". The code is alright it takes the first initial. The problem resides in the fact that just one name cannot be accepted, it has to be better than this (of course). Well my main trouble is I do not know "where to start" I don't know if I need a for loop or whatever. Please I need to accomplish the pset's specs...

This is my code:


int main(void)
   printf("Gimme your name: ");    
   string name = GetString();
       printf("Your initials are: %c\n", toupper (name[0]));

Any help is appreciated. Thank you again!

3 Answers 3


Oh, I almost forget. Those who are struggling with this particular set, I'd suggest the following:

Once you can "print" one letter of the first name (e.g. using the [0] square brackets and the first char of the array) the "real" problem is to print the "ith" character AFTER the space bar given by the user, more clearly: The user types "John Doe" you wanna print just the "D" of "Doe" right? So one solution is use the "isblank()" function for this purpose, after the for loop of course.

Remember to include the header file ctype.h. And do not forget to capitalize with "toupper()" function.

  • Sure, we can use isblank(), but it was never brought up during the lecture. Is it doing us any favor to just worked with a method that abstracts out an opportunity to think critically using the material we were given (during the lecture)?
    – DeltaFlyer
    Nov 25, 2017 at 21:27

In order to find where each name starts, you will have to iterate through the whole string, so yes, you will need a loop :)

  • Thank you 4 the answer. Yep, but I do not know how to implement it, I mean, I don't figure out how to "juggle" with the variables and the loop, just want a little hint for it...
    – Paul_1898
    Sep 8, 2015 at 16:44
  • I'm going to assume that you know how to iterate through a string. If you don't, you should watch the lectures because that's explained by Prof. Malan himself (can't remember in which lecture). How do you usually (in plain written English) recognize when a word ends and a new one begins? How can you tell the difference, for example, between "now here" and "nowhere"? Take the input string from the user, loop through it, and when you find a character that tells you you reached the end of a word, print the next one :)
    – Irene
    Sep 8, 2015 at 19:46
  • Phew! Thank you for your help! Now my code is finished :)
    – Paul_1898
    Sep 9, 2015 at 1:04

Use the function: isspace(); to check whether a character is a space, if it is, print the next character using toupper().

You must log in to answer this question.

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