hey im now starting prog in c++ n im being honest- im REALLY flustered
i have to create a program to get information from a user, put the info to a file, create another program to read from that file, calculate total scores of x amount of students n grade and output to the screen.

i have the parts about getting the info from the user and putting it into a file down...kinda ( there is no space between the variables, and its the loop is not working). i do not know how to ready diff types of data on one line (str, int and double) from the file and into the other prog. im so lost!
here's what i have so far:-

#include <iostream>
#include <fstream>
#include <string>

using namespace std;
main ()

{
      ofStream outFile;
      outFile.open ('records.dat');
 
      string firstName, lastName;
      int count, sc1, sc2, sc3, sc4, sc5 = 0;
      
     while (count <= 5);
        {
           cout << "\nEnter student's first name: "\n";
           cin >> firstName;
           outFile << firstName; 

           cout << "Enter student's last name: "\n";
           cin >> lastName;
           outFile << lastName;

          cout << "Enter 5 scores (of 10 or less) with spaces: \n";
          cin >> sc1 >>sc2 >>sc3 >> sc4 >> sc5;
          count ++;
       }
    return 0
}

(wondering if an array would have worked?)

this is just the first program (decided that i probably should work on 1 at a time)

For next time, please use the code tags

[code] //code goes here

[/code]

Count needs to be initialized to zero before the loop, otherwise you're getting whatever junk is in there upon declaration. If you want a space in your output just do outfile<<firstName<<" "; or wherever you want the spaces.

You are right in wanting to take it one step at a time. Once you get this part working try to write out your other values and see what happens.

thanks i got that prog to work
sori about not using the code tags
working on my second prog in a bit - thx ppl!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.