Adding a word

I am wanting to do code for a basic currency converter. It will basically to be to choose one of three currencies then convert it into US$. So naturally the first part of the code asks which currency you want to convert.

So I manage to get it to ask the Question and then when I type the currency it only prints the first letter. How do I get the whole word onto the screen?

1
2
3
4
5
6
7
8
9
  #include <stdio.h>
int main()
{
char key;
puts("What currency do you want to convert to US$:");
scanf("%c",&key);
printf("You want to convert  %c to US$\n",key);
return(0);
}
you do realize thats C code and not C++ code right? Also char gets one character hence the name character. use string for that and if you have whitespaces at all use getline(cin, key);
Last edited on
Topic archived. No new replies allowed.