Question

How do you add a char to a sentence.

For example I have a player1 and would like to add the player1 to the beginning of the sentence " please enter how many times you would like to shuffle the deck.

I'm used to java where you can just add the + to it to concatenate the variable and string(s)

I have this so far but it doesn't like any of what I have typed:

printf(&player1 + " please enter how many times you would like to shuffle the deck: ");
int numShuf;
scanf("%i", &numShuf);

Any help would be greatly appreciated

Était-ce utile?

La solution

Try this:

printf("%s please enter how many times you would like to shuffle the deck: ", player1);

printf means print formatted, so you can format what you want to print and add the variables in as arguments.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top