Results 1 to 3 of 3

Thread: [+rep] simple c++ help

  1. #1

    Joined
    Apr 2013
    Posts
    84
    Userbars
    3
    Thanks
    26
    Thanked
    21/13
    DL/UL
    30/0
    Mentioned
    14 times
    Time Online
    4d 47m
    Avg. Time Online
    1m

    [+rep] simple c++ help

    i have attached a notepad file which contains data for a project i am doing. The file is supposed to have 3 columns with numbers. i need someone to write a c++ code which puts a space/newline after every 14th character so that the numbers come out proper. Just keep it in a txt file.
    The format should be:
    xxxx xxxx xxxx
    xxxx xxxx xxxx
    xxxx xxxx xxxx

    yea you get the picture. I will FULL(as much as i can rep you) rep anyone who can get this done.
    Attached Files Attached Files
    Last edited by naruto; 06-05-2013 at 10:54 PM.

  2. #2

    Joined
    Apr 2013
    Posts
    84
    Userbars
    3
    Thanks
    26
    Thanked
    21/13
    DL/UL
    30/0
    Mentioned
    14 times
    Time Online
    4d 47m
    Avg. Time Online
    1m
    still need it, if anyone can help it would be greatly appreciated.

  3. #3

    Joined
    Jun 2012
    Posts
    1,699
    Thanks
    876
    Thanked
    2,881/1,142
    DL/UL
    44/1
    Mentioned
    562 times
    Time Online
    118d 6h 45m
    Avg. Time Online
    40m
    Aww man this is what they make u learn in school? This is so basic...

    Just split each letter of the string into a array and loop the array. For every letter have a integer that increases +1 when it hits 14 there should be a space , reset the counter back to 0 and continue looping.


    Infact lets get creative?

    Why not use the split function on (" ") this will split the string into an array at every space so ur array would be like

    key1- 3.95
    key2-0.37
    key3-0.483.94

    Now we can loop the above array keys and check its length using string.length function (w.e it is). If the key length is > 4 then we need to recreate the current key with a space after the 4th letter , else its fine and move on.... Maybe you can get extra points or something like that I think it would be cleaner and you may just get noted for thinking differently (even though you didn't really)
    Last edited by DarkByte; 06-05-2013 at 11:39 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •