Thread: How to export results to file using C language

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

    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
    export the results to file with the following ketqua.txt
    (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
    Henderson, NV
    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
    Vietnamese - DNG Network System
    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
    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
    If you want to print a number with a specific amount of zeros in front of it, you can use e.g.
    printf("%06d", number);
    Of course the same applies for functions like fprintf() which write to a file.

    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:

    My website:
    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, 10:39 PM
  2. Problems passing a file pointer to functions
    By smitchell in forum C Programming
    Replies: 4
    Last Post: 09-30-2008, 02: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, 07:51 PM
  4. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01: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