0

Why won't this output my string vertically?

THanks in advanced, bookmark.

#include <iostream>
#include <string>

using namespace std;
								 
void print (const string & s);
	

void main(){

print("blah");

 system("pause");
}
void print ( const string & s){
	  int i;   
	  int clrscr();  
		for(i=0;i<4;i++)  
 {          
	 cout << "\n %c", s;        
	  }			
	
	} 
v
3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by natha_peepli
0

main() is never void, it always returns an int according to the standard.

As to your actual problem, you are mixing up the syntax for printf (the function in the C standard library) with the syntax for cout. Look up the syntax for cout (or find one of countless examples on this site).

Hint: s[0] is the first character of the string s

Edited by jonsca: n/a

0

Why won't this output my string vertically?

THanks in advanced, bookmark.

#include <iostream>
#include <string>

using namespace std;
								 
void print (const string & s);
	

void main(){

print("blah");

 system("pause");
}
void print ( const string & s){
	  int i;   
	  int clrscr();  
		for(i=0;i<4;i++)  
 {          
	 cout << "\n %c", s;        
	  }			
	
	} 
v

well use stdio.h if u wanna use printf..

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.