![]() |
Why printf?
Why do we use printf? I started c at the beginning of 6 weeks (minus about a week of c++), but knew PHP before that. In PHP you use the print statement where you just go
Code:
<?phpCode:
printf("The variables value is: %d", variable);Can you use print() in c? If so why doesn't FIRST? |
Re: Why printf?
Quote:
Don't forget, not all computers have the same outputs, so you can 'print' to several different things (a printer, a serial connection, a monitor). |
Re: Why printf?
PHP is an interpreted language, but C is compiled. In C, everything in between the quotes is stored verbatim in the binary image that gets executed. By the time the program is compiled, your program no longer knows what the variable names were so it could not parse the variables out of the string. Even if it did know the variable names, it would need special knowledge of where the variable was actually stored.
I can't think of any way that it would even be possible to do this in C without doing some pre-processing before it got to the compiler. |
Re: Why printf?
printf is print formatted
I know that in perl there is both print and printf but printf is far more powerfull |
Re: Why printf?
Quote:
|
Re: Why printf?
Thanks guys, I just wasn't too sure.
|
| All times are GMT -5. The time now is 04:41. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi