Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

C text file

Name: Anonymous 2010-12-14 20:17

Can you guys PLEASE show me a very, very basic C program that writes input to a text file?

Name: Anonymous 2010-12-14 20:23

#include<stdlib.h>
int main(){system("cat > filename"); return 0;}

Name: Anonymous 2010-12-14 20:23

#include <stdlib.h>

int main(void)
{
    system("echo input > file");
    return 0;
}

Name: PHP FAGGOT 2010-12-14 22:16

<?php file_put_contents("filename", "contents"); ?>

Name: Anonymous 2010-12-15 0:37

#include <stdio.h>
#include <stdlib.h>
int main(void) {
  int c;
  while ((c = getchar()) != EOF) putchar(c);
  return ferror(stdin) || ferror(stdout) ? EXIT_FAILURE : 0;
}


This writes input received on stdin to stdout. Redirecting stdout to a file is a job best left to the shell (if you don't know what this means, Google shell redirection).

Name: Anonymous 2010-12-15 1:27

>>5
DON'T HELP HIM!

Name: Anonymous 2010-12-15 2:48

>>2-3 Too fat. That's how you do it properly:

int main()
{
    char buf[256];
    FILE*file = fopen("my","anus");
    while(fread(buf,256,256, stdin)){
        fwrite(buf, 256, 256, file);
    }
}

Name: Anonymous 2010-12-28 7:28

Name: Anonymous 2013-01-19 14:37

/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.

Don't change these.
Name: Email:
Entire Thread Thread List