Click here to Skip to main content
15,910,009 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: ISamplerGrabber future ?? Pin
SoMad28-Mar-13 20:34
professionalSoMad28-Mar-13 20:34 
QuestionTurbo code implementation in C++ Pin
Manoj739025-Mar-13 20:50
Manoj739025-Mar-13 20:50 
AnswerRe: Turbo code implementation in C++ Pin
Jochen Arndt25-Mar-13 22:09
professionalJochen Arndt25-Mar-13 22:09 
GeneralRe: Turbo code implementation in C++ Pin
vikramlinux25-Mar-13 22:39
vikramlinux25-Mar-13 22:39 
GeneralRe: Turbo code implementation in C++ Pin
vikramlinux25-Mar-13 23:17
vikramlinux25-Mar-13 23:17 
QuestionHow can i create a project that it has the same name with an existing project Pin
November 201325-Mar-13 5:33
November 201325-Mar-13 5:33 
QuestionRe: How can i create a project that it has the same name with an existing project Pin
David Crow25-Mar-13 6:17
David Crow25-Mar-13 6:17 
AnswerRe: How can i create a project that it has the same name with an existing project Pin
November 201326-Mar-13 2:56
November 201326-Mar-13 2:56 
AnswerRe: How can i create a project that it has the same name with an existing project Pin
Richard MacCutchan25-Mar-13 7:32
mveRichard MacCutchan25-Mar-13 7:32 
GeneralRe: How can i create a project that it has the same name with an existing project Pin
November 201326-Mar-13 4:03
November 201326-Mar-13 4:03 
QuestionRe: How can i create a project that it has the same name with an existing project Pin
David Crow26-Mar-13 4:13
David Crow26-Mar-13 4:13 
AnswerRe: How can i create a project that it has the same name with an existing project Pin
November 201326-Mar-13 4:18
November 201326-Mar-13 4:18 
AnswerRe: How can i create a project that it has the same name with an existing project Pin
November 201326-Mar-13 20:13
November 201326-Mar-13 20:13 
GeneralRe: How can i create a project that it has the same name with an existing project Pin
Richard MacCutchan26-Mar-13 6:39
mveRichard MacCutchan26-Mar-13 6:39 
GeneralRe: How can i create a project that it has the same name with an existing project Pin
November 201326-Mar-13 20:11
November 201326-Mar-13 20:11 
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 

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.