Thread: infinite loop

  1. #16
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    So, read the records from input, then sort them in RAM and then write them to file.dat. Why do you have to sort the records on the hard disk?

  2. #17
    Registered User
    Join Date
    Aug 2011
    Posts
    385
    Quote Originally Posted by Elysia View Post
    >> fflush(stdin);
    I already told you that's undefined.
    Go back and implement our suggestions before you proceed.
    come on mam.. I am a newbie. I tried to use "std::get.ignore" but it says "error C2228: left of '.ignore' must have class/struct/union". Seriously mam, I am yet to get into this namespace business, and right now I don't understand these errors, so I am clinging on to what I learned in C programming. Please allow me some time to learn..

  3. #18
    Registered User
    Join Date
    Aug 2011
    Posts
    385
    Quote Originally Posted by whiteflags View Post
    Why do you have to sort the records on the hard disk?
    But what's wrong with that...

  4. #19
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by juice View Post
    come on mam.. I am a newbie. I tried to use "std::get.ignore" but it says "error C2228: left of '.ignore' must have class/struct/union". Seriously mam, I am yet to get into this namespace business, and right now I don't understand these errors, so I am clinging on to what I learned in C programming. Please allow me some time to learn..
    That was a typo on my part...
    It should std::cin.ignore().
    Anyway, if you just post errors on the way, we can help you. But if you keep quiet, then we don't know.
    We are trying to steer you into writing safe and portable C++ code. Using C idoms in C++ will get ugly pretty quick.

    If you would just post your errors and your current best attempt instead of trying to rush fixing the problem first... you will learn along the way.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #20
    Registered User
    Join Date
    Aug 2011
    Posts
    385
    Quote Originally Posted by Elysia View Post
    If you would just post your errors and your current best attempt instead of trying to rush fixing the problem first... you will learn along the way.
    I got that.

    Now PLEASE tell me whats wrong with line no. 66...
    Last edited by juice; 03-18-2012 at 03:21 PM.

  6. #21
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by juice View Post
    But what's wrong with that...
    Imagine you were picking grapes. Would you...
    Pick a single grape, walk 200 metres (or 500ft, whatever) to carry it back to the winery, then walk back again pick a single grape, walk back to the winery etc etc?
    Or would you pick a bunch of grapes, perhaps even a dozen bunches of grapes at a time, and then carry them back to the winery?
    (The first one is sorting on disk, the second is sorting in memory)
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  7. #22
    Registered User
    Join Date
    Aug 2011
    Posts
    385
    Quote Originally Posted by iMalc View Post
    Imagine you were picking grapes. Would you...
    Pick a single grape, walk 200 metres (or 500ft, whatever) to carry it back to the winery, then walk back again pick a single grape, walk back to the winery etc etc?
    Or would you pick a bunch of grapes, perhaps even a dozen bunches of grapes at a time, and then carry them back to the winery?
    (The first one is sorting on disk, the second is sorting in memory)
    well, ok, maybe operating on data on the disk is not the best way of doing things, but there should be a reason why it won't work..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. infinite loop
    By juice in forum C Programming
    Replies: 9
    Last Post: 12-18-2011, 12:16 PM
  2. Replies: 3
    Last Post: 10-14-2011, 11:33 PM
  3. Infinite loop!!!
    By Bizmark in forum C Programming
    Replies: 3
    Last Post: 02-21-2009, 12:09 PM
  4. stays in loop, but it's not an infinite loop (C++)
    By Berticus in forum C++ Programming
    Replies: 8
    Last Post: 07-19-2005, 11:17 AM
  5. Infinite Loop!!!
    By Frantic- in forum C++ Programming
    Replies: 3
    Last Post: 12-13-2004, 06:39 PM