placing output of printf in memory: formatting strings

Zack C. Sessions session at seq.uncwil.edu
Thu Jun 20 06:04:15 AEST 1991


luntz at acsu.buffalo.edu (jon e luntz) writes:

>	I'm working with a serial device on a machine where I need to use a
>device driver to access the port (ie. I cannot just fopen the port).  The way
>the driver works is it takes the output string straight from memory.  What I'd
>like to do is to be able to write formatted output to memory, such as that from
>a printf or fprintf.  Is there any way to fopen a string pointer or a memory 
>location, or maybe some way to redirect output to memory temporarily?  I'd
>appreciate any advice.

Use sprintf(). For example,

	int number;
	char string[80];
	sprintf(string,"%d",number);


Zack C. Sessions
session at seq.uncwil.edu
	  ^^^
	   |
	   +--->  Note! Username is session, NOT sessions. Not my fault!
					Ask my SysAdmin why!!



More information about the Comp.lang.c mailing list