Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
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 23-Mar-13 4:44am
Comments
ThePhantomUpvoter at 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 at 23-Mar-13 14:50pm
   
the problem is I noob in programming >,<
ThePhantomUpvoter at 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 at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

I code it in C,
#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.
  Permalink  
Comments
moonstalker at 24-Mar-13 10:37am
   
thank you anyway, I will try this
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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[^]
  Permalink  
Comments
moonstalker at 23-Mar-13 14:51pm
   
ok, I will try this, thanks
H.Brydon at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  

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

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 Sergey Alexandrovich Kryukov 130
4 DamithSL 105
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 23 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100