Variadic function

This is a discussion on Variadic function within the C Programming forums, part of the General Programming Boards category; Now come on, Tater, you're making fun of me....

  1. #16
    Registered User
    Join Date
    Feb 2011
    Posts
    126
    Now come on, Tater, you're making fun of me.

  2. #17
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,738
    There is something called a format string attack, but printf("%s", something); prevents it so percents or anything else aren't really a problem.

    That being said, I would think that the only reason printf would fail, being used normally, is if stdout was never opened. And in general, I would depend on ferror() and perror() actually get useful information about what went wrong with a stream operation, rather than just a number.

    You probably want to create a temporary new file, remove the old one, and then rename the new file the same as the old one. That way if something does go wrong while dumping the original file is unchanged.

  3. #18
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,563
    Quote Originally Posted by Richardcavell View Post
    You sure? I think safeprint is safe for strings that include %s.

    Richard
    Yeah, you're right. I misread your implementation of safeprint.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling C in Visual Studio 2005
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-16-2009, 03:25 AM
  2. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  3. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21