How to save data to a file using FILES in C

This is a discussion on How to save data to a file using FILES in C within the C Programming forums, part of the General Programming Boards category; How to save data to a file using FILES in C??? pls show me some formats......

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,471
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    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, 09: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

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