1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Rep Power

    Printf not working when outputting text

    Hey guys,


    I am making a program which takes a file input which contains data which is meant to be copied into the program. It uses > to output anything in printf to text

    So the expression i use to call the program is ./program file > output. But when I use that expression nothing gets copied into the program or outputted into the file

    But when i use ./program file the data from the file gets copied in but obviously there is no output

    It appears to me that using > output causes printf to stop printing to anywhere including the console and only allows fprintf(stderr,.....) which prints to the console

    Any ideas?
  2. #2
  3. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Rep Power
    Redirection doesn't affect that printf transfers information onto stdout. stdout, however, could point anywhere. Try this adorable program before you post your own program and input.

    int puts(const char*s);
    int main() { return puts("Bonjour tout le monde."), 0; }

    The point is, either your program doesn't work as you expect or you don't understand the environment.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    May 2004
    Rep Power
    Normally, if you don't redirect the program output, it should show up on the console. That would indicate that perhaps you are never writing anything to stdout, possibly you are not reading anything from the file either?

    Unless perhaps you aren't running a console application? Some windowing environments just swallow anything you put on stdout.

    Have you tried stepping through your program in a debugger?
    I no longer wish to be associated with this site.

IMN logo majestic logo threadwatch logo seochat tools logo