-
Jan 20th, 2013, 10:36 AM
#1
Thread Starter
PowerPoster
[C++] - strange things:(
Code:
int main()
{
char name[255];
while (name !="exit")
{
std::cout<< "Insert your name:\n";
std::cin>>name;
std::cout<< "Hi "<<name<<"\n";
std::cin>>name;
std::cout<<name;
}
return 0;
}
why these code takes very time to open the exe?
why when i type "exit", the program don't close it?
(only with me these stupid errors)
-
Jan 20th, 2013, 12:06 PM
#2
Re: [C++] - strange things:(
Comparing name and "exit" will only compare the pointers, there will be no string comparison. Take a look at strcmp
-
Jan 20th, 2013, 12:18 PM
#3
Thread Starter
PowerPoster
Re: [C++] - strange things:(
Originally Posted by Atheist
Comparing name and "exit" will only compare the pointers, there will be no string comparison. Take a look at strcmp
still not working
Code:
#include <iostream.h>
#include <string.h>
int main()
{
char name[255];
do
{
cout<< "Insert your name:\n";
cin>>name;
cout<< "Hi "<<name<<"\n";
cin>>name;
}
while (strcmp (name, "exit")==false);
return 0;
}
anotherthing: now the 'std::' was give me an error, that's why i delete... strange
-
Jan 20th, 2013, 12:38 PM
#4
Thread Starter
PowerPoster
Re: [C++] - strange things:(
ok.. now works fine;
Code:
#include <iostream.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char name[255];
do
{
system("cls");
cout<< "Insert your name:\n";
cin>>name;
cout<< "Hi "<<name<<"\n";
cin>>name;
}
while (strcmp (name, "exit")!=0);
return 0;
}
but why takes time to open(in IDE: Visual C ++ 6))?
-
Jan 21st, 2013, 02:02 AM
#5
Re: [C++] - strange things:(
Do you mean it takes a long period of time to open the project, or to run the project?
If it is the latter, I would suggest you look in the output-window of the build process. What is happening when its being slow?
-
Jan 21st, 2013, 06:53 AM
#6
Thread Starter
PowerPoster
Re: [C++] - strange things:(
Originally Posted by Atheist
Do you mean it takes a long period of time to open the project, or to run the project?
If it is the latter, I would suggest you look in the output-window of the build process. What is happening when its being slow?
when i change the code and click in '!'(build command), the IDE takes very time to open the new exe. but after these, if i click again, don't happens
is about being windows 7?
(the output-window seems ok. after saying 'Linking...', it takes 1 minute or 2 for open the exe)
-
Jan 21st, 2013, 07:52 AM
#7
Thread Starter
PowerPoster
Re: [C++] - strange things:(
anotherthing: if i do these(take off the loop):
Code:
#include <iostream>
#include <string.h>
#include <stdlib.h>
using namespace std;
int main()
{
char name[255];
//do
//{
system("cls");
cout<<"Insert your name.\n";
cin>> name;
cout<< "Your name is: " << name << "\n";
cin>>name;
//}
//while(strcmp(name,"exit")!=0) ;
return 0;
}
the program executes(in IDE) much more faster(normal speed).
so??? it's my system(windows 7 for the Visual C++6) or otherthing?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|