Thread: About C programming help on file handling

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    1

    About C programming help on file handling

    Hi, I am relatively new to programming enviroment.

    I want to ask something regarding file handling. My problem is as follows:


    Input
    My program is to read from a file named "input.txt." The input consists of T test cases. The number of test cases T is given in the first line of the file. For each test case, two strings and x and y (|x|<50, |y|<50) are given in the first and the second line, respectively. The alphabet is the set of the lowercase English characters.

    Output
    My program is to write to a file named "output.txt." For each case, print an value s of x and y in the first line and its length in the second line, respectively. Note that there can be more than one value but I should print only one.

    The following shows sample input and output for two test cases.
    input.txt
    2 ( Since value at line 1 is 2, four data possible)
    ababc (1st character string)
    bcba ( 2nd character string)
    aabbabab (3rd character String)
    abababa (4th character String)

    output.txt
    bc (/ba/bb) ( Comparing 1st character String and 2nd character String)
    2
    abbaba (/ababab) ( Comparing 3rd character string and 4th character string)
    6



    can anyone help me solving this problem.

  2. #2
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    Why don't people read the FAQ?
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Well what have you managed to achieve so far?

    A good first program is to read the whole file and print it straight back unmodified (which proves you can a) read the file and b) read it properly).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Drunken Progammer CaptainMorgan's Avatar
    Join Date
    Feb 2006
    Location
    On The Rocks
    Posts
    45
    can anyone help me solving this problem.

    Sure we can.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating File Handling Functions
    By td4nos in forum C Programming
    Replies: 6
    Last Post: 06-26-2009, 11:43 AM
  2. basic file handling problem
    By georgen1 in forum C Programming
    Replies: 4
    Last Post: 03-05-2009, 06:21 AM
  3. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  4. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 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