HOw to change this coding into printf?

Hi,
I have to change this into the old style (using printf)

---------------------------------------
if(count==1)
cout<<" 0"<<matrix[p-1][q-1];
else
cout<<" "<<matrix[p-1][q-1];

---------------------------------------

I try this but it is wrong, I don't understand function of <<matrix;

if(count==1)
prtinf(" 0")<<matrix[p-1][q-1];
else
printf(" ")<<matrix[p-1][q-1];


could you help? pls, thanks
printf is the C version of cout.

The correct use of it is as follows:
 
printf("Here is a decimal: %d, and here is a hex value: %h, and here is a float: %f", decVal, hexVal, floVal);


The %d is a place holder to output a decimal value, and you can find it after the terminating ". So decVal will print out in decimal the value in decVal. The same is true for %h, hexadecimal and hexvalue, and %f, float value, and floVal.

1
2
3
4
float floVal = 3.00;
int hexVal = 15;
int decVal = 10;
printf("Here is a decimal: %d, and here is a hex value: %h, and here is a float: %f.\n", decVal, hexVal, floVal);


This will produce the following:
Here is a decimal: 10, and here is a hex value: F, and here is a float: 3.00.

Does this help?
it's not a stream, you can't use the stream operator... <<

this is also cplusplus.com


But here's a guide, just keep the rest in mind eh?

http://www.keil.com/support/man/docs/c51/c51_printf.htm
Topic archived. No new replies allowed.