0

Hello!

I have what I want to print to file current printf-ing on my console. Can I have some help getting it to do the same, only this time to file please. I can't get it to work.

Many thanks

for(i= 0; i <= k; i++)
    {
    add = (unsigned char *)s; 
    data = *add; 
    printf("data = %02x \n\r",data);
    s++;
    }
3
Contributors
4
Replies
6
Views
5 Years
Discussion Span
Last Post by deceptikon
1

Open a file stream using fopen(), then call fprintf() instead of printf(). Alternatively, you could redirect stdin into a file, but I don't get the impression that this is what you want.

0

What deceptikon said, except instead of "redirect stdin", it should read "redirect stdout"... :-) Another case of the keyboard mis-interpreting the user's intent... :-)

0

except instead of "redirect stdin", it should read "redirect stdout"... :-)

I have an excuse for that brain fart this time. I spent a large portion of the afternoon working on the input half of a standard C library implementation, so I had stdin on the brain. Give it a few days and I'll type stdout when I mean stdin. ;)

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.