Readinf text file

Discussion in 'C' started by Kodila, May 13, 2009.

  1. Kodila

    Kodila New Member

    Joined:
    Apr 29, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Hi again.

    I got a littel problem, i just cant find the solution.
    I read the txt file, then print it and its all fine.
    I can search some chars and calculate how many that kind of chars are in txt file.
    But are there posibiliti to input lets say 'a' and then it will search first 'a' letter and next lets say 10 chars.
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Yep, so you would need to read a character from the user, open and search the file for that character in exactly the same way you currently do, then just count off 10 characters and do whatever you want to do with them.
     
  3. Kodila

    Kodila New Member

    Joined:
    Apr 29, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    I know that, but i cant figur out how to count them...with somekind of array?loop?, mayby there are somewhere somekind of tutorial or help file???:).
     
  4. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,342
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
    http://www.crackingforfun.blogspot.com
    You know how to find the first occurrence of 'a', but you don't know how to count next 10 chars ?!

    You may use :
    Code:
    char ExtractedChar(10);
    ifstream FileIn("myfile.ext");
    .
    // search for first occurrence
    .
    for (int i = 0; i < 10; ++i) ExtractedChar[i] = FileIn.get();
    .
    // continue
    .
     
  5. Kodila

    Kodila New Member

    Joined:
    Apr 29, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    tnx il try that.:pleased:
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice