Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
R

ramrooney

@ramrooney
About
Posts
2
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • sopen() function in filehandling - "C"
    R ramrooney

    Hi, This is possible, when the file mentioned is not present in the corresponding path or the file name is wrong you get the file handle as -1. And its crashing because, you are trying to close a invalid file handle in close() api.

    Managed C++/CLI help

  • (ask) need help how to divide a file into some file
    R ramrooney

    Hi moonstalker, Here is the solution for your problem,

    #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.

    C / C++ / MFC help tutorial c++
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups