try using system("shutdown -s -f -t 00");
Its not the best solution, but whether it works or not, it will be informative.
Yes -- I just tested it on my Vista Home and it works perfectly.
try using system("shutdown -s -f -t 00");
Its not the best solution, but whether it works or not, it will be informative.
Yes -- I just tested it on my Vista Home and it works perfectly.
this works
enum Days { Sunday, Monday, Tuesday, Wednesday,Thursday, Friday, Saturday };
void operator++(Days& d)
{
if( d == Saturday )
d = Sunday;
else
d = (Days)((int)d + 1);
}
int main()
{
Days d = Sunday;
do
{
switch(d)
{
case Sunday: cout << "Sunday\n"; break;
case Monday: cout << "Monday\n"; break;
case Tuesday: cout << "Tuesday\n"; break;
case Saturday: cout << "Saturday\n"; break;
default: cout << (int)d << "\n"; break;
}
++d;
}while( d != Sunday );
}
>>i wrote this is this correct
Don't know -- did you test it?
Tourists coming to USA don't drink our water either -- I knew someone from Australia and he told me that he can't drink our water.
ftell() returns a long int, and the max value is declared in limits.h. If yours is like mine then the 4 gigs is too big.
Delete line 3 (system(...) because its not needed. Otherwise, your line #1 looks ok to me, as long as you are running as administrator account.
As nucleon illustrated above it will depend on the operating system. His code is *nix only and possily MAC. For MS-Windows, see this article
If you want to write your own mini-dos then you can not use the system() function for anything.
You can get list of files and sub-directories in MS-Windows by using the FindFirstFile() and FindNextFile() win32 api functions (look them up with google to find exact syntax.) You can find all sorts of examples on the net, just use google.
int** foo()
{
int i;
int** array = malloc(100 * sizeof(int *));
for(i = 0; i < 100; i++)
array[i] = malloc(20 * sizeof(int)); // allocate 20 integers
return array;
}
int main()
{
int ** array = foo();
}
lines 8 and 9. Files can not be opened outside a function like you have it. Move both those lines down to within main() (line 14).
line 16: eof() will not give you the file size, it just tells you that the end-of-file has been reached and nothing more. To get the file size
// set file pointer to end-of-file
infile.seekp(0, ios::end);
// get file location
N = infile.tellg();
line 22: Not only doesn't that work with most compilers (I think it will when the newest c++ standards are implemented), but its also wrong. The value of N (see above) will not tell you the number of integers in the file, but how many characters are in the file. For example the number 100 will be counted as 4 or 5 depending on the operating system (3 digits plus '\n').
To get the actual number of integers in the file you will have to read each line and count them as you go along.
line 25: eof() doesn't work like that either because it will cause your program to process the last line twice. A better solution is like this
int i = 0;
while( infile>>P[i]>>V[i] )
{
// blabla
++i;
}
Where did you get those titles in the first list?
So what is the problem? Out of energy? What is that supposed to mean? And the program just goes to the Game Menu because that's exactly what you told it to do (line 35).
No, you apparently lost. It's not really anything to us if we convinced you not to cheat. Had you studied like you should have then you would not have had to turn in a blank piece of paper as your assignment. You apparently have a bad case of poor time management, and after nearly 10 years in college I would have though you should have at least learned how to study and manage your time more effectively.
Two threads merged.
you need to explain better what you want.
Before jumping off the deep end of the pond you first have to learn to swim. read some tutorials about loops and all will become clear to you. Remember, google is your friend.
Great news :) Now you can go on to more advanced problems.
on line 21 you need to look up the username in a database and, if found, verify the password.
Put lines 10 thru 21 in a loop so that the program can start all over again if the username and/or password are incorrect (not found in the database)
Note that the database can be as simple as a text file or as complicated as an SQL Server. How you do that part is up to you to decide when you design your program.
There isn't a standard way to do it -- depends on the operating system. You might try calling onexit(), but it may not get called when Ctrl-C is hit.
Where exactly is Jonathanland? I never heard of it and apparently google hasn't either.
i have pyschological problems guys,
Oh so now you think we are your phyciatrist? Sounds like you are making a career as a student. Hurry up and get your degree before you die of old age :)
Just count the lines as they are being read
std::string line;
int counter = 0;
while ( getline(myfile, line) )
{
++counter;
cout << left << setw(4) << counter << line << "\n";
}
Any reason you posted that code, which can not be compiled with anything but Turbo C compiler?
See post #71 of this thread: Is that link supposed to exist any more? Dani posted it in that thread about a year ago (see post #53)
video tutorials are next to worthless. Why? Because its nearly impossible to reference certain material without viewing the entire video! Lets say you are confused about loops, and loops are discussed near the end of a 2-hour video tutorial. Well, would you rather sit there a watch the entire tutorial or just open a book and go directly to the page that discusses loops?
No money for books? Well, you will get exactly what you pay for. Get a free video tutorial and your education will be next to worthless.
>>char* delString(char s1, char s2)
those two parameters are wrong. They should be std::string, not char (which is just a single character)
"error correction code" could mean almost anything. Here is just one example:
std::string name;
while(true)
{
cout << "Enter your name\n";
cin >> name;
if( name != "Jones" )
cout << "Error\n";
else
break;
}
Or do you want to know about try/catch blocks?
Isn't cheating exactly the cause of our global financial crises were are now in? Whats-His-Name started a pyramid scheme that cheated thousands of people out of several Billion dollars? I read an article in local newspaper about a woman in Missouri who did a similar thing but on a much smaller thing to the farmers in Missouri.
If you teach students that cheating is ok in college, then why not extend that concept to cheating in the business world?
you have to create one big string that includes all the variables
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
string ip
string command;
cout << Enter an ip;
cin >> ip;
command = "ping " + ip;
system(command.c_str()); //// this is the problem. how do i enter the value of "ip" here?
system("PAUSE");
return EXIT_SUCCESS;
}
You put the guards in the *.h files that you wrote, not the STL or other system files. If you are getting errors, then you didn't do it correctly, and you should post the header file w/guards so we can see what you did.
//"xmlParser.h"
#ifndef XMLPARSER_H
#define XMLPARSER_H
// stuff goes here
#endif
delete and delete[] don't erase the memory locations, only frees it up for other uses as Narue previously said. The data you stored at that location is still there, but delete invalidated the pointer you had. Its always a good rule-of-thumb to reset pointers to NULL after calling delete or delete[] so that the program doesn't mistakenly attempt to reference the deleted memory location.
int main()
{
int *t =0;
t = new int [10];
t[0] = 3;
t[1] = 7;
cout<<t[0]<<" "<<t[1]<<endl;
delete[] t;
t = NULL;
cout<<t[0]<<" "<<t[1]<<endl; // this line will now produce an error
cin.get();
return 0;
}
The reason your file is 8 time bigger is because you are forgetting that each bit (in this format) represents a pixel. You are reading (and writing) 1152 * 813 bytes, but that is actually how many bits you should be reading! There will probably be some padding at the end of the picture rows, so there will be more than 1152 * 813 / 8 bytes. You will have to look up the info for the padding. You could try assuming that it's simply to the nearest byte and see if that works, but it could be rounded off to 4 bytes. At any rate, that's your basic problem.
Yes I think you might be right about that because that is just about the number of bytes my version of the program actually read.
After some testing with the code you just posted I found that the file marbles.pbm does not contain enough data --
Here is the output of my version of the read function:
Error reading bin file
Expecting 936576 bytes but found only 117071 bytes.
and the code I changed
void CarregaPNM::LoadPixels(){
<snip>
else if( MV[1] == '4' ){//if is a bin pixel map (PBM P4)
long max = width*height;
long i;
unsigned char* buf = new unsigned char[max];
readPNM.read((char *)buf,max);
if( (i = readPNM.gcount()) != max)
{
cout << "Error reading bin file\n";
cout << "Expecting " << max << " bytes but found only " << i << " bytes.\n";
}
for(i = 0; i < max; ++i)
img_pix[i].rgbb[0] = buf[i];
delete[] buf;
My guess is the reason the file is not big enough is because the remaining unwritten bytes are some default value, such as -1 (or 0x255), 0 or some other default value. From this information I would presume not only do you have to save width and height, but also the number of bytes that are actually in the file so that you can write back out exactly what was read, which might be a value less than width*height.
Is this c++ ??? Never heard of XPath.
The COM object I worked with return HRESULT and the BSTR was a parameter
BSTR b = 0;
HRESULT hr = ComObject->Foo(&b);
But you have to check exposed function prototypes in the COM object's header file.
can you use the functions in time.h? If you can, just populate a struct tm, call mktime() to get the time_t object. Once you have the two time_t objects call difftime().
i think a month ago i found that forum, then i saw that total number of threads in the forum was 20, so i was a little frustrated. our company extended the functionality on the raima database and there is no documentation for those additional methods..
It's not Raima's fault there is no documentation for those extensions. But I see what you mean about the lack of threads -- they must have cleaned out all the old ones or started a new forum recently because I know it was fairly popular when I was using it 20 years ago.
Thread closed.
bring your forum to here, we as daniweb citizens wouldnt bother to go there :)
Why? Don't limit your programming experience just to DaniWeb. If you have questions about specific database then get it from the horse's mouth.
I used Raima databases 20 years ago when I was writing MS-DOS 6.X programs. At that time Raima was a hierarchical database (non-SQL) and quite easy to use. Several years ago Raima expanded its product to an SQL database, but I have not used it. AFAIK its language is pretty SQL standard, so if you read about one SQL database you can apply it to most any others.
Not necessarily -- if the images will never change then just put them in the resource section.
Are you implying that I've mellowed out, AD?
Yes -- people tend to do that as we get older :)
julienne is a nice name by the way, i will name my daughter like that if i have one oneday
Enough of this Narue (Julienne) fasination -- had you posted like this several years ago when she first joined DaniWeb she would have ripped your throat out :)
MFC has about a year's learning curve to learn it well, but you can get a basic program going in just a day or so. I assume OpenGL and wxWidgets is several months too. In all cases you need a pretty firm grasp of c++ fundamentals.
You could use pure win32 api functions -- here's a tutorial.
The class that was Jencas previously mentioned was of type CDialog. He was trying to describe how to create an event handler, which apparently you already know how to do.
You said in your original post you want to "load and image" when you hit a button. All that involves is LoadBitmap()
What operating system and compiler are you using ? *nix, MS-Windows, and MAC have very different drawing api functions.
If you are using Microsoft compilers on MS-Windows then you could probably write such a program using MFC, which is a c++ class that is like a wrapper for win32 api functions.