1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

need some c++ help please

Discussion in 'Software Development' started by linkinworm, Oct 12, 2008.

Thread Status:
Not open for further replies.
Advertisement
  1. linkinworm

    linkinworm Thread Starter

    Joined:
    Dec 9, 2007
    Messages:
    160
    hi, i was asked to write a small program for my work placement that i have to do for college. but i cant seem to get else if statement right cna anyone help, i want it so that if it finds the updates it will say "updates found, installing...", but if it doesnt find the update it will say "no updates found"

    Code:
    #include <iostream>
    #include "timer.h"
    using namespace std;
    int myArray[2];
    
    void main(){
    
    
    	cout << ("searching for updates... ");
    
    	 system("C:/windows/softwaredistribution/download/87e2eea2fdb074b2f6c6d4e787ea2d13/update/update.exe");
    cin >> myArray[0];
    	 if myArray[0] = true; cout << ("updates found, installing... ");
         else 
    		 cout << ("no updates found");
    	 }
    	
    system("pause");
    }
    
    
     
  2. -Fabez-

    -Fabez-

    Joined:
    Jul 28, 2008
    Messages:
    1,899
    By updates do you mean Windows Updates or do you mean updates for a program that has been created by you or the company ? If it is for Windows Update then you can open browser window at the Windows Update website, if it is not then could you elaborate more please ?
     
  3. linkinworm

    linkinworm Thread Starter

    Joined:
    Dec 9, 2007
    Messages:
    160
    yea, basicaly, its to do with windows update, its complicated why i want to use this program to install them. but yea its like my own program to install the update. i just want it to look more pro to say i found updates, if it found updates, or to say no updates if nothing was found
     
  4. mt2002

    mt2002

    Joined:
    Sep 14, 2005
    Messages:
    919
    There are several problems with the code that should have produced numerous compile time errors. See below...

    All errors are in Red
    All errors fixed are in Blue
    All other code is unchanged.

    Code:
    #include <iostream>
    #include <cstdlib>            // for system()
    using namespace std;
    
    int myArray[2];
    
    [COLOR="Red"]//ISO C++ requires main must return an int
    //void main() {
    [/COLOR][COLOR="Blue"]
    //corrected version:
    int main () {
    [/COLOR][COLOR="Red"] 
      // std::cout overloads the << operator so the () isnt needed
      //cout << ("searching for updates... ");
    [/COLOR][COLOR="Blue"] 
      //corrected version
      cout << "searching for updates..." << endl;
    [/COLOR]
       system("C:/windows/softwaredistribution/download/87e2eea2fdb074b2f6c6d4e787ea2d13/update/update.exe");
       cin >> myArray[0];
    [COLOR="Red"]
       // Four problems here. The ; will end the if expression, The use of = instead of test of equality ==, And no () for the expression. Finally, the cout expression is wrong again.
       //if myArray[0] = true; cout << ("updates found, installing... ");
    [/COLOR][COLOR="Blue"] 
       //corrected version
       if (myArray[0] == true) {
          cout << "updates found, installing..." << endl;
       }[/COLOR]
       else {
    //      cout << ("no updates found");
          cout << "no updates found" << endl;
       }
    
       system("pause");
    }
    I hope this helps a little... :)
     
  5. xtreampb

    xtreampb

    Joined:
    Jan 30, 2007
    Messages:
    189
    here if yall need some more addtiional help try this place. www.dreamincode.net They specilize in helping people with questions on programming. Of course they make sure that you aren't being lazy and require that you post some code like you have here before they help. and they will show you what is going wrong, why that is wrong, and what to do to fix it. No matter how simple it is.
     
  6. linkinworm

    linkinworm Thread Starter

    Joined:
    Dec 9, 2007
    Messages:
    160
    cool thanks guys, i actualy did get it corrected, but then i found out that the update was wrong. so im back to square one again untill i can talk to someone about how to install the downloaded updates useing my program
     
  7. kirah28

    kirah28

    Joined:
    Oct 17, 2008
    Messages:
    6
    i have many.. different kind of program in C++ because my prof is so strict if you need some help pls pm message me. i can show you all my program we done..
     
  8. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/758381

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice