Jump to content

Sendou

Members
  • Posts

    3
  • Joined

  • Last visited

Posts posted by Sendou

  1. This will only work in MSVS, in other cases you have to

    #include <windows.h>

    This also means that the code won't be portable to other architectures. I usually use the following function (not sure if you've gotten as far as functions), although understanding how it works may be out of your grasp at the moment. But don't worry, as you progress in your learning you'll soon understand it easily:

     

    #include <ctime>
    #include <cstdio>
    
    void timePause(int seconds) 
    {
       clock_t endwait;
       endwait = clock () + seconds * CLOCKS_PER_SEC ;
       while (clock() < endwait) {}
    }
    
    int main()
    {
      printf("And we shall wait for 3 seconds before the window closes...");
      timePause(3);
      return 0;
    }
    

    -Source

     

    I think the best thing to do is to use the Code::Blocks IDE, which pauses the console by itself. And it's also great in debugging and quite frankly in every other regard as well, at least in my opinion.

     

    Thanks, that does indeed work to pause the console for a set amount of time and does feel a bit more proper than what I was doing before.

     

    I do have another question though.

     

    int main()
    {   
      cout << "Wait forever.";
    
      while (1 > 0) {}
      return 0;
    }
    

     

    Anything wrong with doing it this way to make a console window stay open indefinitely while not requiring user input?

     

    I'm not familiar with the proper standards of programming and won't be taking my Intro CS course until next semester, so I'm really just playing around in MSVC to kind of dip my feet in before I actually start any learning

     

    I'm thinking it's a bad way to do it because the program would endlessly calculate if 1 > 0...

     

    Yeah, nevermind, I think I answered my own question lol... the difference in CPU process is quite noticeable between waiting for user input to close the window and trying to keep it open indefinately using a while line. (0% CPU vs ~50% CPU)

  2. If one would take a computer and study it from A to Z, from the very atoms inside inside those elements found in the many metals found in them to the very output produced by the many instructions, assembly languages, programming languages etc - one would, basically be a god-blessed genius.

     

    My question is - is there a field of study that teaches one about computers in such a manner? Computer Science, IMO, would seem like it teaches the most obvious first-hand foundations of said technology. Thus would cover, I think, only the most modern interpretations of these lovely machines like how circuitry works, how you can make a LED calculator with some resistors and a basic conductive plate with metals conductors on it.

     

    I mean, I want to know how we took electricity and combined it with the elements from A to Z in order to produce this marvelous technological leap in the last 100 years.

     

    I mean, if we keep going the way we are going, we are just going to have to sit and eat. Before we become so mundane - I want to know how it got to where we are. O.o

     

    What are your suggestions, what should I study to know E-V-E-R-Y-T-H-I-N-G about computers?

     

    Double Major in Computer Engineering + Electrical Engineering w/ a minor in Computer Science

    Plus self-study every waking hour that you have available to you. (Chemistry/Mathmatics/History/Physics/etc)

    Obtain certifications in every possible field. (CompTIA, CCNA, MSCE)

    Work Part-Time in various industries dealing with computer systems/it/software engineering/etc.

     

    Then you might scratch the surface, or your brain might just asplode.

     

    I'd think you would be intellectually satisfied just going for a B.S. in CompE/EE and then working your way into a good graduate school for further studies.

  3. #include <stdio.h>
    int main()
    {
         printf("whatever");
    
         system("pause>nul");
    
         return 0;
    }
    

    I usually use a system pause>nul. This will leave the CMD window open without requesting any user input. But I'm a newbie, so forgive me if I'm wrong. :P But I'm not sure if it works in C, since I've been learning C++ with MS Visual Studio 2010 Pro.

     

    Reading online, this doesn't look like it's meant to be standard practice, soooo... take it for what it's worth. It gets the job done, but there has to be a better way.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.