Thread: Help In C files

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    12

    Smile Help In C files

    I have to create a ranges out of these lines in file

    Input:
    ------------
    9849201348
    9849201349
    9849201350
    9849201400
    9849203000
    9849209000
    9849210000
    9849215000
    9849220000

    output
    -------
    range 1: 9849201348 to 9849210000

    range 2: 9849215000 to 9849220000

    Usually there will be millions of lines of code .The numbers will be in sorted order but not in a consecutive manner...like after 9849201350 ,9849201400 may appear...The difference between

    9849201400 -9849201350 =50 .If the difference between 2 numbers is greater than 10000 then we have to take the numbers encountered as one range.

    i,e range 1: 9849201348 to 9849210000 for the above example...

    If i follow the rule like taking the first line in the series and adding 10000 and taking it as one range ..But the number may not be present in the file.so shall i have to go linear way or what...Can anyone please send me the code for getting the output as shown above in C language....

  2. #2
    former member Brain Cell's Avatar
    Join Date
    Feb 2004
    Posts
    472
    Can anyone please send me the code for getting the output as shown above in C language....
    Sure , how much will you pay?
    My Tutorials :
    - Bad programming practices in : C
    - C\C++ Tips
    (constrcutive criticism is very welcome)


    - Brain Cell

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    12
    no ideas r what

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Oh sure, we have plenty of ideas. No one here however is going to simply do everything for you. Go read the forum announcements and try your post again after you've done some work on it. Mmmm watermelon!

    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    12

    Help in C files

    Suppose if i have to read two lines in a loop then how should i do that

    for example below r 2 lines and how should i get the values and store them...

    9849201348
    9849201349


    fp=fopen("input.txt","r");

    if (fp==NULL)
    {
    printf ("\n File does not exist....");
    exit(0);
    }

    while (fgets(ln,100,fp)!=NULL)

    {

    /* Here i get only one line ..... *///


    how should i store 2 values and compare that ...

    }
    pls help me

  6. #6
    Registered User
    Join Date
    Nov 2004
    Location
    USA
    Posts
    516
    use code tags
    you will find that in the sticky at the top of the forum
    Code:
    >+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.

  7. #7
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    1) Go read the announcements like I told you.
    2) Use code tags, as the announcements tell you.
    3) You could always store them as arrays. There are various ways to compare these.
    4) If you yourself were comparing them, how do you do it? Write it out on paper in simple steps. Then try to do those steps in code.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ressources files
    By mikahell in forum Windows Programming
    Replies: 4
    Last Post: 06-19-2006, 06:50 AM
  2. add source files to embedded VC 4.0
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 03:28 AM
  3. *.cpp and *.h files understanding
    By ElastoManiac in forum C++ Programming
    Replies: 4
    Last Post: 06-11-2006, 04:45 AM
  4. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:46 AM
  5. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 02:41 PM