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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to read a set of numbers from a textfile to a 2D array?

How to read a set of numbers from a textfile to a 2D array?

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++iosdata-structurestutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KaKa
    wrote on last edited by
    #1

    Hi, I need to read 5 rows by 5 columns of numbers from a text file into a 2D integer array. How do I do it in C++? e.g 10101 00011 10111 01110 10010 I've already created a 2D array and the necessary statements which are used to read from a text file. i.e int data[5][5]; ifstream inClientFile("Data.txt", ios::in);

    T 1 Reply Last reply
    0
    • K KaKa

      Hi, I need to read 5 rows by 5 columns of numbers from a text file into a 2D integer array. How do I do it in C++? e.g 10101 00011 10111 01110 10010 I've already created a 2D array and the necessary statements which are used to read from a text file. i.e int data[5][5]; ifstream inClientFile("Data.txt", ios::in);

      T Offline
      T Offline
      ThatsAlok
      wrote on last edited by
      #2

      first read all data in any string then reterive useful text from it!

      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

      cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

      H 1 Reply Last reply
      0
      • T ThatsAlok

        first read all data in any string then reterive useful text from it!

        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

        cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

        H Offline
        H Offline
        Hamid Taebi
        wrote on last edited by
        #3

        And it seems he needs to convert string to int atoi :)

        _**


        **_

        WhiteSky


        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

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