2

I'm having trouble with pset2 initials.c My program compiles and passes each output test, however after each test I get "wasn't expecting "Please enter your name:" The problem states that we are to create a program that prompts the user for his/her name. I am confused as to why I am getting this error. Any help greatly appreciated.

And just so I feel like a real doofus, I cannot figure out how to cut and paste my code into this post. I am using a mac, not sure if this is an issue with appliance, but I can't seem to cut and paste using shortcuts within gedit either.

1
  • try using the 'Unity' mode in VMware .. use command + C / command + V to copy/paste. Hope it helps.
    – jzz
    Commented Mar 23, 2015 at 11:40

2 Answers 2

2

Remove the printf function that contains "Please enter your name:", because due to the pset specs you shouldn't print anything out before reading the user's input.

In order to avoid this kind of errors in the future, you will need to follow the pset specs precisely, a great tool that might help you do so, is by checking the staff's implementation of the pset in this case using the command ~cs50/pset2/initials, if your solution behaves differently then you will need to review back your code. This error might happen while your code is logically right, but it's a"Presentation error", meaning that you printed something into the screen in a wrong format or that it wasn't supposed to be printed due to the pset specs.

For copying and pasting your code, I think this might depend on the virtual machine software you're using whether it's vmware or something else. Try to use command+c for copying, then command+v for pasting, or ctrl+c for copying, then ctrl+v for pasting.

2
  • I thought I had followed the instructions precisely, they state that our program is to "prompt the user" to input their name however it seems no such prompt is required. Thanks for your advice. Will try the command key, fingers crossed, its a pain in the rear. Commented Feb 21, 2015 at 9:15
  • You're welcome, anytime you had a question just put it here or in the Facebook group and I'm sure everyone will be of help. Don't worry while you're still at the beginning, I also got stuck many times when I first entered the course, but with time and practice things become more easier and more intuitive. Stay passionate! :)
    – Mana
    Commented Feb 21, 2015 at 21:25
0

To answer your first question, this is because the checker checks all the output that your program produces. It doesn't expect any prompt before the user types in the name. So just remove your printf() statement before you collect input from the user and you should be all right.

For your second question: are you saying that the keyboard shortcuts don't work? If so, try using Ctrl key instead of Cmd. So, Ctrl-X, Ctrl-C, Ctrl-V. I think, that is the default binding in Linux.

You must log in to answer this question.

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