printf to cout help

Hey everyone, I'm writing a piglatin conversion program that works...however my teacher wants the basic cout instead of printf. I wrote my code using printf before I saw this in the notes but now whenever I try to change it over it produces an error. Any help is appreciated! I have highlighted the line

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//This program will read in a string and then translate it into piglatin

#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;

void PLC (char *x)
{
	char *word = x;
	while (word != NULL)
	{
        
		printf("%s%c%s", word+1, word[0], "ay "); //&&&&&&&&&&&&&&&&&&&
		word = strtok(NULL, " ");	
	}
	
	cout << ("\n\n");
}

int main ()
{
	char input[1000];
	char *token;
	
	cout << ("Enter a Phrase to Be Translated to Pig Latin: ");
	gets (input);
	cout << ("\n");
	token = strtok (input, " ");
	PLC(token);
	
	
	system("pause");
	return 0;
}//End Main
The syntax for cout is like this:
1
2
 
cout << "Stuff in a string " << variablex; //variablex could be an int or a char or bool for example.  


So it's not simply a case of putting cout where printf was.
I understand the syntax and how to use the cout statements, I just don't know how to fix line 14 so that when I run the program with cout it still works. Thats the problem I'm running into
nevermind, I was able to figure it out, I just replaced
 
printf("%s%c%s", word+1, word[0], "ay ");


with

 
cout << word+1 << word[0] << "ay ";
Topic archived. No new replies allowed.