Path: utzoo!utgpu!news-server.csri.toronto.edu!torsqnt!hybrid!scifi!bywater!uunet!uunet!ukma!eng.ufl.edu!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ucbvax!FKRS1.PHC.CHALMERS.SE!biorn From: biorn@FKRS1.PHC.CHALMERS.SE (Bjorn Sandell) Newsgroups: comp.unix.aix Subject: sprintf (again) Message-ID: <9106120920.AA08552@fkrs1.phc.chalmers.se> Date: 12 Jun 91 09:20:08 GMT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 32 Let's se if I can be more specific :) First a "disclaimer": I don't know much AIX and even less C. This is a 320 machine and uname -a says AIX fkrs1 1 3 000023913100. I'm trying to port xmail. It usally coredumps, but once I got an error message saying something like "can't open file /tmp/tmpxxxx_" where xxxx was a number. After some browsing through the sorce files I (think I) found the line where this filename should be created. It was a sprintf statement, and I've tried to replace it with strcpy and strcat as follows: /* if ((fp = fopen((char *)sprintf(s, "%s_", tmpName), "w")) != NULL) {*/ strcpy(s,tmpName); strcat(s,"_"); if ((fp = fopen(s, "w")) != NULL) { Now it seems to find the /tmp/tmpxxxx_ file (no errors at least;), but it eventually coredumps anyway. The question is do I have to rewrite all sprintf's this way or is there an easier way? Is there anything wrong at all with the original line? Any and all help is welcome! Bjorn ZDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD? 3 But, but, everyone KNOWS that all the answers can be found in manuals! 3 3 Don't you still have your copy of "Life: A User's Manual", that came with 3 3 your wetware? :) 3 @DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDY