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. Managed C++/CLI
  4. Inputing data from .txt to array.

Inputing data from .txt to array.

Scheduled Pinned Locked Moved Managed C++/CLI
data-structureshelp
2 Posts 2 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.
  • R Offline
    R Offline
    Ramper
    wrote on last edited by
    #1

    I have a program that is able to take the numbers out of the .txt if it is just a list of numbers. Problem is, I have a file with Names before the grades. I believe i need to set up another array inside the first one to fill with names. The .txt file will look like: Name grade grade grade grade grade grade grade grade grade grade Name ... Have 15 Names with 10 grades under each. I guess what i'm trying to do is take the strings out of the file. Is there a way to take the strings(there is a string every 11 lines) Here is what i have now: #include #include #include #include #include #include using namespace std; const int TESTS = 10; const int STUDENTS = 15; void displayGrades( int [][TESTS] ); void getGrades( int [][TESTS]); int main() { int data[STUDENTS][TESTS] = {0}; getGrades( data ); cout <> data[student][test]; } } } void displayGrades( int data[][TESTS] ) { double testTotal = 0.0; double classTotal = 0.0; double squared = 0.0; double var = 0.0; double sdev = 0.0; int mxm = data[0][0]; int min = data[0][0]; cout << "\nGrade summary" << endl; cout << "--------------" << endl; cout << left << setw(7) << "Student" << right << setw(5) << right << "Ex1" << setw(7) << "Ex2" <

    J 1 Reply Last reply
    0
    • R Ramper

      I have a program that is able to take the numbers out of the .txt if it is just a list of numbers. Problem is, I have a file with Names before the grades. I believe i need to set up another array inside the first one to fill with names. The .txt file will look like: Name grade grade grade grade grade grade grade grade grade grade Name ... Have 15 Names with 10 grades under each. I guess what i'm trying to do is take the strings out of the file. Is there a way to take the strings(there is a string every 11 lines) Here is what i have now: #include #include #include #include #include #include using namespace std; const int TESTS = 10; const int STUDENTS = 15; void displayGrades( int [][TESTS] ); void getGrades( int [][TESTS]); int main() { int data[STUDENTS][TESTS] = {0}; getGrades( data ); cout <> data[student][test]; } } } void displayGrades( int data[][TESTS] ) { double testTotal = 0.0; double classTotal = 0.0; double squared = 0.0; double var = 0.0; double sdev = 0.0; int mxm = data[0][0]; int min = data[0][0]; cout << "\nGrade summary" << endl; cout << "--------------" << endl; cout << left << setw(7) << "Student" << right << setw(5) << right << "Ex1" << setw(7) << "Ex2" <

      J Offline
      J Offline
      Jun Du
      wrote on last edited by
      #2

      This is Managed C++/CLI forum. Post it to VC++/MFC forum. You may get some replies there.

      Best, Jun

      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