Thread: Need a urgent help, Test in hours time!!

  1. #1
    Registered User
    Join Date
    Feb 2012

    Need a urgent help, Test in hours time!!

    Someone please help me I'm having my exam tmrw! So nervous
    Im having trouble combining both the .txt files in to 1 file and run the program which I have coded.

    I want the output of this program to be like:

    James 90
    Thomas 50
    Sheila 60
    Jessica 20
    Precillia 10
    2 out of 5 of the class has failed the test.


    I've attached the necessary files. here is my program;

    #include <iostream>
    #include <fstream>
    #include <cstring>
    using namespace std;
    int main()
    string getcontent;
    ifstream openfile ("names.txt") ;
    if (openfile.is_open())
    while(! openfile.eof())
    openfile >> getcontent;
    cout << getcontent << endl;
    int marks[100];
    int x=0,fail=0, pass=0;
    fstream textfile;"marks.txt");
    while(! textfile.eof()){
    textfile >> marks [x];
    cout << fail << " students out of "<< (fail+pass) << " did not pass.";
    return 0;


  2. #2
    Registered User
    Join Date
    May 2009
    FYI: You posted poorly C++ code in a C sub-forum.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Time between Military Hours
    By StarOrbs in forum C++ Programming
    Replies: 18
    Last Post: 03-01-2005, 06:46 PM
  2. Time to test your C++ abilities...
    By Darkman in forum C++ Programming
    Replies: 19
    Last Post: 01-10-2004, 09:58 AM
  3. Replies: 3
    Last Post: 06-13-2003, 06:47 AM
  4. URGENT!!!!9 hours left!!!
    By emiyca in forum C++ Programming
    Replies: 2
    Last Post: 10-29-2001, 08:34 AM
  5. Test of avatar - don't waste time reading this.
    By sean in forum A Brief History of
    Replies: 17
    Last Post: 10-10-2001, 05:30 PM