Click here to Skip to main content
15,886,100 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralDialog or “dynamic” Menu? Pin
Vaclav_23-Mar-13 4:16
Vaclav_23-Mar-13 4:16 
GeneralRe: Dialog or “dynamic” Menu? Pin
Richard MacCutchan23-Mar-13 6:08
mveRichard MacCutchan23-Mar-13 6:08 
GeneralRe: Dialog or “dynamic” Menu? Pin
pasztorpisti24-Mar-13 4:53
pasztorpisti24-Mar-13 4:53 
QuestionProblem with flockfile and funlockfile Pin
noislude23-Mar-13 4:09
noislude23-Mar-13 4:09 
Question(ask) need help how to divide a file into some file Pin
moonstalker23-Mar-13 3:49
moonstalker23-Mar-13 3:49 
AnswerRe: (ask) need help how to divide a file into some file Pin
dusty_dex23-Mar-13 4:36
dusty_dex23-Mar-13 4:36 
GeneralRe: (ask) need help how to divide a file into some file Pin
moonstalker23-Mar-13 8:53
moonstalker23-Mar-13 8:53 
AnswerRe: (ask) need help how to divide a file into some file Pin
ramrooney26-Mar-13 7:39
ramrooney26-Mar-13 7:39 
Hi moonstalker,

Here is the solution for your problem,

C#
#include "stdafx.h"
#include <string>


int _tmain(int argc, _TCHAR* argv[])
{
    FILE *fHnd = fopen("C:\\sample.txt", "r+");

    char *pBuffer = new char[5];
    for (int nFileCnt = 0; nFileCnt < 10; nFileCnt++)
    {
        std::string strFileName = "";
        sprintf((char *)strFileName.c_str(), "C:\\File%d.txt", nFileCnt);
        FILE *fHndWrite = fopen(strFileName.c_str(), "a+");
        for (int nCnt = 0; nCnt < 10; nCnt++)
        {
            fgets(pBuffer, 5, fHnd);
            fwrite(pBuffer, 1, 3, fHndWrite);
        }
        fclose(fHndWrite);
    }
    fclose(fHnd);

    return 0;
}


In this code assuming you keep your numbers in the file "Sample.txt" file and after you run the code you will get 10 files generated with the names such as File0, File1 etc. Each of these files consist of 10 numbers.

Bye.
SuggestionRe: (ask) need help how to divide a file into some file Pin
Shaheed Legion27-Mar-13 0:48
Shaheed Legion27-Mar-13 0:48 
QuestionHelp needed to print the value nth number raised to the power n. Pin
Rajdeep_22-Mar-13 21:46
Rajdeep_22-Mar-13 21:46 
AnswerRe: Help needed to print the value nth number raised to the power n. Pin
Richard MacCutchan22-Mar-13 23:47
mveRichard MacCutchan22-Mar-13 23:47 
GeneralRe: Help needed to print the value nth number raised to the power n. Pin
Rajdeep_23-Mar-13 0:08
Rajdeep_23-Mar-13 0:08 
AnswerRe: Help needed to print the value nth number raised to the power n. Pin
V.J.NAGA VARA PRASAD23-Mar-13 4:36
V.J.NAGA VARA PRASAD23-Mar-13 4:36 
AnswerRe: Help needed to print the value nth number raised to the power n. Pin
Vaclav_23-Mar-13 4:52
Vaclav_23-Mar-13 4:52 
GeneralRe: Help needed to print the value nth number raised to the power n. Pin
Richard MacCutchan23-Mar-13 6:00
mveRichard MacCutchan23-Mar-13 6:00 
SuggestionRe: Help needed to print the value nth number raised to the power n. Pin
David Crow23-Mar-13 16:05
David Crow23-Mar-13 16:05 
QuestionDirectX SDK – which version? Pin
Vaclav_22-Mar-13 8:38
Vaclav_22-Mar-13 8:38 
AnswerRe: DirectX SDK – which version? Pin
dusty_dex22-Mar-13 8:45
dusty_dex22-Mar-13 8:45 
QuestionUse InternetSetOption() to change proxy Pin
Oren_Davod21-Mar-13 23:03
Oren_Davod21-Mar-13 23:03 
AnswerRe: Use InternetSetOption() to change proxy Pin
Richard MacCutchan21-Mar-13 23:38
mveRichard MacCutchan21-Mar-13 23:38 
Generalc++ queue OUTPUT ? Pin
kr kumar21-Mar-13 9:33
kr kumar21-Mar-13 9:33 
GeneralRe: c++ queue OUTPUT ? Pin
jeron121-Mar-13 10:18
jeron121-Mar-13 10:18 
QuestionRe: c++ queue OUTPUT ? Pin
David Crow21-Mar-13 17:08
David Crow21-Mar-13 17:08 
QuestionChoosing which information that Windows Vista's folder contents displayer is to display Pin
Anthony Appleyard21-Mar-13 3:41
Anthony Appleyard21-Mar-13 3:41 
AnswerRe: Choosing which information that Windows Vista's folder contents displayer is to display Pin
David Crow21-Mar-13 4:44
David Crow21-Mar-13 4:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.