Thread: Program Looping question

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    6

    Thumbs up Program Looping question

    Hi I just started to learn C++ so please forgive me for any newbie things I say during this post. I went through the tutorial on this site and made it through the beginners section. What I didnt learn was how to loop programs like calc.exe over and over again as a joke or to make my own startup folder. Please any suggestions on how to set this up is appreciated. Thank you

  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    82
    Infinite loops are simple with a while or do-while loop.

    Code:
    #include <iostream>
    
    int main()
    {
       while(true)
       {
    
           std::cout << "Stuff happens here" << std::endl;
        
       }
    }

  3. #3
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Code:
    int main()
    {
        for(;;)
        {
            //put your program in here
        }
        return 0;  //this line will never be reached
    }
    how do you mean 'make my own startup folder'? if you mean the folder 'my documents' points to in windows, I believe that's written in the registry somewhere. in linux, type usermod -d path username
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  4. #4
    Registered User
    Join Date
    Feb 2005
    Posts
    6
    What I meant by start up folder was to make a program using C++ that could open up all my rendering and cad programs instead of having to select the ones i need all the time. Being as lazy as i am I like to have light wave rhino and Bryce open instead of me opening each one at a time. I dont want to put them in windows start up folder becasue i dont go on my computer everytime jus to do cad and rendering. So i just wanted to make a program that could auto execute those programs. Maybe I should just make a quick batch file and stop worrying how to make it in C++ Thanks for your guys help by the way.

  5. #5
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    assuming you're using windows, know exactly where these files are, and simply double-clicking them will open them the way you want, you can use system calls:
    Code:
    #include <cstdlib>
    
    int main()
    {
        system("start path to file");
        system("start path to second file");
        return 0;
    }
    be warned, however, that this introduces the possibility of a major security breach. if you're only using this on your machine, this shouldn't be a problem though. also note that if you move the files you'll have to change your code and recompile the program.

    perhaps a better way of doing this is writing a batch script:
    Code:
    @echo off
    start path to first file
    start path to second file
    save that as something.bat, put it on your desktop, and run it...

    edit: I didn't even read the last line of your post until just now, but yes, that would be the better way to do it...
    Last edited by major_small; 02-11-2005 at 12:44 AM. Reason: reread previous post...
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  6. #6
    ---
    Join Date
    May 2004
    Posts
    1,379
    loop programs like calc.exe over and over again as a joke
    is that funny is it?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 01:42 AM
  2. Complete n00b Question, Client -> Sever MMO Program?
    By Zeusbwr in forum Networking/Device Communication
    Replies: 4
    Last Post: 07-28-2005, 08:33 PM
  3. Replies: 26
    Last Post: 06-15-2005, 02:38 PM
  4. Question about K&R program
    By Aerie in forum C Programming
    Replies: 15
    Last Post: 04-24-2005, 07:09 AM
  5. Replies: 8
    Last Post: 03-26-2002, 07:55 AM