[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



> I don't have my C book on me and I need to print debug info to a text
> file. Does anyone have a code snippet ob how to open a file and print to
> it?

Try this:

#include <stdio.h>
int
main()
{
    FILE* fp = NULL;
    fp = fopen("/tmp/debug.log", "a+");
    fprintf(fp, "%s\n", "Your message here");
    fclose(fp);
}

Jim Patterson.


</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00870" href="msg00870.html">[ale] comcast static IP?</a></strong>
<ul><li><em>From:</em> pete.hardie at gmail.com (Pete Hardie)</li></ul></li>
<li><strong><a name="00872" href="msg00872.html">[ale] gcc programming</a></strong>
<ul><li><em>From:</em> ringo at margaritasrus.com (ringo)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00879.html">[ale] comcast static IP?</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00881.html">[ale] gcc programming</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00876.html">[ale] gcc programming</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00881.html">[ale] gcc programming</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00880"><strong>Date</strong></a></li>
<li><a href="threads.html#00880"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>