How to export results to file using C language

This is a discussion on How to export results to file using C language within the C Programming forums, part of the General Programming Boards category; You Dear programmers. You want to write a small program the following in C with the following requirements. I know ...

  1. #1
    Registered User
    Join Date
    Feb 2010
    Location
    Vietnamese - DNG Network System
    Posts
    2

    How to export results to file using C language

    You Dear programmers. You want to write a small program the following in C with the following requirements.
    I know you only education only save.
    Title article:
    allows users to enter into a series of four integer numbers. Input process ends when the user

    Click the "T".
    When the input end of the production results of the input file c: \ ketqua.txt elephant following specifications:

    eg I type in the following
    0001
    0005
    0254
    1234
    export the results to file with the following ketqua.txt
    0000001,000005,000254,001234
    (ie add two numbers 0 to the result. At the same time each result added a comma).
    Thank your help

    // I am a beginner so your sympathy for me
    Last edited by Viết Sang; 02-10-2010 at 06:14 PM.

  2. #2
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    We tend not to write the code for you but if you at least try to start we can help from there....
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  3. #3
    Registered User
    Join Date
    Feb 2010
    Location
    Vietnamese - DNG Network System
    Posts
    2
    Thank you for visiting my article

    I understand this is not acceptable for a programmer, while I dont know well about the C language for much. This is the fault of myself, I do not have a document to refer to the beginning of this language (my own and no one up carefully for me)

    // Version Information sympathy

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    In general, it sounds like you'll need to
    #include <stdio.h>

    as your only header file, and then start right in on your

    int main() {

    and declare 4 integers:

    int num1, num2, num3, num4;

    and maybe use a simple scanf("%d", &num1), repeating 3 more times with the other int variable names.

    I'm not sure what you need to do with the numbers then, but code this much up, and let's see where you stand with this, OK?

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    If you want to print a number with a specific amount of zeros in front of it, you can use e.g.
    Code:
    printf("%06d", number);
    Of course the same applies for functions like fprintf() which write to a file.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 11:39 PM
  2. Problems passing a file pointer to functions
    By smitchell in forum C Programming
    Replies: 4
    Last Post: 09-30-2008, 03:29 PM
  3. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 08:51 PM
  4. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 02:19 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM

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