- #1
Ilikecereal
- 17
- 1
What's the purpose of cout.write. Isn't it pretty much the same thing as cout?
For eg, the following code would work the same with cout and cout.write
int main( )
{ char string[80] ;
cout<<"Enter string\n" ;
cin.getline(string, 80) ;
int x1 = strlen(string) ;
for(int i = 0 ; string != '\0' ; i++)
if(string == ' ')
string = '-' ;
cout<<"The changed string is\n" ;
cout.write(string, x1) ;
return 0 ;
}
For eg, the following code would work the same with cout and cout.write
int main( )
{ char string[80] ;
cout<<"Enter string\n" ;
cin.getline(string, 80) ;
int x1 = strlen(string) ;
for(int i = 0 ; string != '\0' ; i++)
if(string == ' ')
string = '-' ;
cout<<"The changed string is\n" ;
cout.write(string, x1) ;
return 0 ;
}