Click here to Skip to main content
16,011,680 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Multiple Resource Files Pin
Nick Blumhardt29-Apr-01 20:40
Nick Blumhardt29-Apr-01 20:40 
GeneralRe: Multiple Resource Files Pin
Nick Blumhardt29-Apr-01 21:46
Nick Blumhardt29-Apr-01 21:46 
GeneralRe: Multiple Resource Files Pin
Erik Funkenbusch29-Apr-01 23:26
Erik Funkenbusch29-Apr-01 23:26 
GeneralDate/Time Pin
William Bartholomew29-Apr-01 15:43
William Bartholomew29-Apr-01 15:43 
GeneralRe: Date/Time Pin
markkuk29-Apr-01 23:01
markkuk29-Apr-01 23:01 
GeneralBeginer question Pin
29-Apr-01 14:09
suss29-Apr-01 14:09 
GeneralDo your own homework... Pin
29-Apr-01 15:55
suss29-Apr-01 15:55 
GeneralRe: Beginner question Pin
Michael Martin29-Apr-01 16:11
professionalMichael Martin29-Apr-01 16:11 
You are only ever going to be working with the last two numbers read, as you are not testing to see if num or nextnum are larger than largest before over writing the value. If the file contains only one column of numbers you only need to read into num (infile >> num) and also have the one if statement testing against largest in the while loop.

Try the following.

int main ()
{
    int num, nextnum, largest;
    ifstream infile;
    infile.open ("testfile");
    infile >> num >> nextnum;
    largest = 0;

    while (!infile.fail())
    {
        if (num > largest)
        {
            largest = num;
        }

        if (nextnum > largest)
        {
            largest = nextnum;
        }
        infile >> num >> nextnum;
    }

    cout << "Largest: " << largest << endl;
    infile.close ();
    return 0;
}


Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
QuestionCalling a dll function from __asm blocks? Pin
mvworld29-Apr-01 12:02
mvworld29-Apr-01 12:02 
GeneralHowto interpret Security ACL in AccessPermission subkey of Registry Pin
Alfonso29-Apr-01 0:51
Alfonso29-Apr-01 0:51 
QuestionUsing MFC classes in Win32 app?? Pin
29-Apr-01 0:02
suss29-Apr-01 0:02 
AnswerRe: Using MFC classes in Win32 app?? Pin
29-Apr-01 3:45
suss29-Apr-01 3:45 
AnswerRe: Using MFC classes in Win32 app?? Pin
peterchen29-Apr-01 7:45
peterchen29-Apr-01 7:45 
QuestionCalling Dll function from assembler code? Pin
mvworld28-Apr-01 14:54
mvworld28-Apr-01 14:54 
AnswerRe: Calling Dll function from assembler code? Pin
Masaaki Onishi28-Apr-01 15:43
Masaaki Onishi28-Apr-01 15:43 
QuestionError in runtime Dll linking? Pin
mvworld28-Apr-01 14:53
mvworld28-Apr-01 14:53 
AnswerRe: Why didn't you check the result of the function? Pin
Masaaki Onishi28-Apr-01 15:30
Masaaki Onishi28-Apr-01 15:30 
AnswerRe: Error in runtime Dll linking? Pin
Michael Dunn28-Apr-01 17:07
sitebuilderMichael Dunn28-Apr-01 17:07 
GeneralRe: Error in runtime Dll linking? Pin
mvworld29-Apr-01 2:27
mvworld29-Apr-01 2:27 
AnswerRe: Error in runtime Dll linking? Pin
29-Apr-01 8:36
suss29-Apr-01 8:36 
GeneralRe: Error in runtime Dll linking? Pin
mvworld29-Apr-01 11:53
mvworld29-Apr-01 11:53 
Generalbuilding a custom data provider Pin
Ernesto Moscoso Cam28-Apr-01 9:41
Ernesto Moscoso Cam28-Apr-01 9:41 
Questionhow get rid of the null character in a BSTR string? Pin
chenzhu28-Apr-01 4:21
chenzhu28-Apr-01 4:21 
AnswerRe: how get rid of the null character in a BSTR string? Pin
Masaaki Onishi28-Apr-01 7:15
Masaaki Onishi28-Apr-01 7:15 
GeneralRe: how get rid of the null character in a BSTR string? Pin
chenzhu28-Apr-01 16:23
chenzhu28-Apr-01 16:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.