Thread: How to save data to a file using FILES in C

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    1

    How to save data to a file using FILES in C

    How to save data to a file using FILES in C???

    pls show me some formats...

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Code:
    #include <stdio.h>
    #include <fcntl.h>
    #include <string.h>
    
    typedef int FLIES;
    
    int main (int argc, char *argv[]) {
    	char content[]="data";
    	FLIES away=open(argv[1],O_WRONLY | O_CREAT), x=1;
    
    	if (!(argv[1])) { puts("You didn't specify a filename."); return -1; }
    	if (write(away,content,strlen(content))<3) perror("write");
    	close(away);		
    	return 0;
    }
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 04-15-2009, 10:35 AM
  2. ordered linked list
    By redmondtab in forum C Programming
    Replies: 48
    Last Post: 10-22-2006, 06:09 AM
  3. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  4. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM