Click here to Skip to main content
15,914,608 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
so here it is, I really dont know how to program

here the problem :

I have a file .txt format, in which there are many number sequentially down.
for example :
+1
+2
+3
+4
+5
etc...

eg: my data have 100 number down, I have to divide them into 10 parts. later the file become 10 file .txt format, in which there are number 1 - 10 (part one), 11 - 20 (part two), 21 - 30, etc ...

and the program must be made from C++. Thanks for help
Posted
Comments
[no name] 23-Mar-13 10:01am    
So open the file, read 10 lines from the file, write to first file, read next 10, write to next file. What is the problem exactly?
moonstalker 23-Mar-13 14:50pm    
the problem is I noob in programming >,<
[no name] 23-Mar-13 17:34pm    
No that is not a problem at all. Being a "noob" is meaningless. Either you have tried to do it yourself or not. If you have tried to do it yourself you must have run into some problem. If you have not tried it yourself then this is just being lazy and getting someone to do your own work for you.
moonstalker 24-Mar-13 10:35am    
how do you know? >,<
my knowledge for programming is low, I learned pseudocode only before. And I no idea to convert it to code

I code it in C,
XML
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(int argc, char** argv){
        int i,j;
        char filename[6],context[10];
        strcpy(filename, "0.txt");
        freopen("input.txt","r",stdin);
        for(i=0; i<10; i++){
                filename[0] = '0'+i;
                freopen(filename,"w",stdout);
                for(j=0; j<10; j++){
                        scanf("%s",context);
                        context[strlen(context)] = '\n';
                        printf("%s",context);
                }
        }
        return 0;
}


C++ is the same.
 
Share this answer
 
Comments
moonstalker 24-Mar-13 10:37am    
thank you anyway, I will try this
This should get you on your way:
http://msdn.microsoft.com/en-us/library/vstudio/y52yxde8.aspx[^]

There should be lots of options if you use Google[^]
 
Share this answer
 
Comments
moonstalker 23-Mar-13 14:51pm    
ok, I will try this, thanks
H.Brydon 23-Mar-13 17:27pm    
The msdn link you provide is for C++/CLI and won't work for generic C++.
Most of the hits at the google search are also C++/CLI.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900