PDA

View Full Version : [+rep] simple c++ help



naruto
06-04-2013, 10:49 PM
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.

naruto
06-05-2013, 10:54 PM
still need it, if anyone can help it would be greatly appreciated.

DarkByte
06-05-2013, 11:33 PM
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)