Thread: Reading a text file string by string and taking their specific characters.

  1. #1
    Registered User
    Join Date
    Mar 2016
    Posts
    1

    Reading a text file string by string and taking their specific characters.

    Hello. I have x40 text files with 3 strings. I have taken all of their 2nd strings with getline function and wrote them to a new text file. It looks like this:


    4001 121125 5e+07 1.61401 0.00118607 1 9929166 6909475 1271116 1399686 151330 148624
    4001 121125 5e+07 1.61325 5.4648e-05 1 19543361 13434019 2626510 3016553 198133 194521
    4001 121125 5e+07 1.61407 0.000206556 1 8696655 5978504 1117929 1261023 145019 141940
    4001 121125 5e+07 1.60799 0.000394664 1 380216 238085 33160 45680 30523 29885

    ...

    My question is, i want to pass the first, second, third, fourth, fifth and sixth character(number) of the string, by the way the sixth character is always 1 and i want after that part. More, from starting after 1 of every string, all i got is 6 characters(numbers) in one string; i want to take the other number after it and the other number after it too, but also i want to sum the other two and last two and wrote all of these to a new file. But i tried many things nothing worked well. I faced with ridiculous arrays etc. Please help me. If you are confused, look after 1, i want to take first character after 1, the second and want to sum the other two and the last two in each string. I have x40 strings in one text file like this.

  2. #2
    Guest
    Guest
    You need to formulate your problem more clearly, this explanation is very obscure. Give and example of your input data, and of the output (or intermediate step) you wish you arrive at. Post an example of your current code.

  3. #3
    Registered User
    Join Date
    Dec 2010
    Location
    Trinidad, CO (log cabin in middle of nowhere)
    Posts
    148
    I agree with Adrian. I can't make sense of it. I'm sure folks would help if you could explain yourself better.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ignoring specific characters in a string
    By seanksg in forum C Programming
    Replies: 11
    Last Post: 05-02-2011, 06:08 PM
  2. storing characters read from text file in 2 different string
    By rcplguy15 in forum C++ Programming
    Replies: 2
    Last Post: 09-25-2010, 04:25 AM
  3. Searching a specific string/word/etc in a text file?
    By zacharyrs in forum C Programming
    Replies: 5
    Last Post: 11-29-2009, 07:54 PM
  4. Reading characters from string/file in blocks of 10
    By Z070111 in forum C Programming
    Replies: 4
    Last Post: 09-26-2009, 08:11 PM
  5. Identifying specific characters in a string
    By London Fog in forum C Programming
    Replies: 8
    Last Post: 08-14-2009, 12:59 PM

Tags for this Thread