 <p>This depends on how your <code>struct</code> is defined, whether or not you want your output to be human-readable, and whether or not the output file is meant to be read on a different architecture. </p> <p>The <code>fwrite</code> solution that others have given will write the <em>binary representation</em> of the struct to the output file. For example, given the code below:</p> <pre><code>#include &lt;stdio.h&gt; int main(void) { struct foo { int x; char name1[10]; char name2[10]; } items[] = {{1,"one","ONE"}, {2,"two","TWO"}}; FILE *output = fopen("binio.dat", "w"); fwrite( items, sizeof items, 1, output ); fclose( output ); return 0; } </code></pre> <p>if I display the contents of <code>binio.dat</code> to the console, I get the following:</p> <pre> john@marvin:~/Development/Prototypes/C/binio$ cat binio.dat oneONEtwoTWOjohn@marvin:~/Development/Prototypes/C/binio$ john@marvin:~/Development/Prototypes/C/binio$ od -c binio.dat 0000000 001 \0 \0 \0 o n e \0 \0 \0 \0 \0 \0 \0 O N 0000020 E \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 0000040 \0 \0 \0 \0 002 \0 \0 \0 t w o \0 \0 \0 \0 \0 0000060 \0 \0 T W O \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 0000100 \0 \0 \0 \0 \0 \0 \0 \0 0000110 </pre> <p>The integer values show up as garbage (not reproduced above) because they've been stored as the byte sequences 01, 00, 00, 00 and 02, 00, 00, 00 (x86 is little-endian), which are not printable characters. Also note that all 10 characters of <code>name1</code> and all 20 characters of <code>name2</code> are written to the file, which may or may not be what you want.</p> <p>The situation gets even more complicated if your struct contains pointers, because what gets stored to the file is the pointer value, not the thing being pointed to:</p> <pre><code>#include &lt;stdio.h&gt; int main(void) { struct foo { int x; char *name1; char *name2; } items[] = {{1,"one","ONE"}, {2,"two","TWO"}}; FILE *output = fopen("binio.dat", "w"); fwrite( items, sizeof items, 1, output ); fclose( output ); return 0; } </code></pre> <p>This time I get</p> <pre> john@marvin:~/Development/Prototypes/C/binio$ cat binio.dat ��������john@marvin:~/Development/Prototypes/C/binio$ john@marvin:~/Development/Prototypes/C/binio$ od -c binio.dat 0000000 001 \0 \0 \0 260 205 004 \b 264 205 004 \b 002 \0 \0 \0 0000020 270 205 004 \b 274 205 004 \b 0000030 </pre> <p>Note that none of the strings appear in the file at all; if you read this file in with a different program, all it will see are (most likely) invalid addresses. </p> <p>If you want your output to be human-readable <em>and</em> you want to be able to read those values in on a different architecture, you almost have to go with formatted output, meaning you have to write each member separately:</p> <pre><code>#include &lt;stdio.h&gt; int main(void) { struct foo { int x; char *name1; char *name2; } items[] = {{1,"one","ONE"}, {2,"two","TWO"}}; FILE *output = fopen("binio.dat", "w"); int i; for (i = 0; i &lt; sizeof items / sizeof items[0]; i++) { fprintf(output, "%d %s %s\n", items[i].x, items[i].name1, items[i].name2); } fclose( output ); return 0; } </code></pre> <pre> john@marvin:~/Development/Prototypes/C/binio$ cat binio.dat 1 one ONE 2 two TWO </pre> <p>You can certainly wrap that operation in a function of your own, something like</p> <pre><code>int printFoo( FILE *output, const struct foo item ) { return fprintf( output, "%d %s %s\n", item.x, item.name1, item.name2); } </code></pre> <p>but in the end, that's about as simple as it gets.</p> <p>The <code>fwrite</code> solution works great if you're not concerned about readability and portability, but you still have to be careful if you have any pointer members within the struct. </p>