Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you can use win32 api functions (scroll down to bottom for GetPrivateProfile??? functions)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Thanks for the reply.

I actually don't understand the size of B. There's only one private function in B. What made the size to be 4? For A, because the long int takes 4 bytes, I can understand the size is 4.

Thanks!

class B also includes class A, therefore sizeof(B) is 4 because class A contains a long integer, which on most compilers sizeof(long) = 4. If you remove class A from class B, then sizeof(B) = 1, which is the smallest amount allowed for any class.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I thought struct wasn't used in c++??,

structs are ok in c++, but they behave like a class except the defulat access is public.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

your program compiled without error with my compiler -- VC++ 6.0 on Windows XP. what compiler are you using? If its really old, such as Turbo C++, then the program may not compile because the compiler is just too ancient.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

My solution would be to write a public get function and use it in the loop instead of attempting to accessing the private member directly.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
fin.seekg( 0, ios::end )	// Find file size
fileSize = fin.tellg( );

if( fileSize < sizeof( int ))	// Need atleast one in

Is the file a binary file or text file? If you view it in Notepad or some other text editor are the numbers readable? If they are, then more than likely it is a text file which means the test you are using to see if the file contains an integer will not work. Why? because the number '1' is only one byte long, not four bytes. Use Notepad or some other text editor to write the number '1' to a file then check the file size with Explorer or some other command-line program (depending on the os you are using). The file size will be from 1 to 3 depending on whether it contains the CR, or CR/LF line terminators.

>>fin<<count; // First int tells the number of ints in the file
this is wrong. should be
fin >> count;

And the extraction operator >> is for text files, not binary files. If the file is truely binary then use this
fin.read((char *)&count, sizeof(int));

>>fin<<numbers;
again, you used the wrong operator
fin >> numbers;


for( i = 0; i < count; i++ )
{
	fin<<numbers[i];
//	if( fin.bad( ))         // Or shoud I use fin.fail( )? It wont be EOF
//		           // Should this be checked each time?
	...// Error		
}

this is …

SpS commented: Good~~SunnyPalSingh +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

20 Marlboro Lights are £5.47 which is just over $10,

OMG and I thought ours were expensive:eek: I know the price of gas is about twice as ours too.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

So much for having personal views and strong stands on religion, politics, or culture.

There are appropriate times and places for discussing those things. For example: www.stltoday.com/forums. But I don't think it is appropriate at any time on DaniWeb because it is for IT related topics, not discussions of hot-topic social/political issues.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Bleh..what a thing to say....:twisted:

when you start getting old the second thing to go is eyesight.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I smoked since high school, and just got the guts to stop in Sep 2001. One of the main reasons I stopped was cost -- the cost nearly $5.00 USD per pack in my area, and its a lot more expensive than that in other parts of USA. It was like tossing $5.00 out the window every time I drove past a store. And I was smoking up to 5 packs a day!

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what is the error message? have you granted yourself permissions in the directory that contains the cgi program and the program itself to run the program?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

provides a forum for intellectual exchange among members.

That disqualifies me :mrgreen:

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This thread has a lot of links

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

he guys -- no point getting all worked up over proof because it simply doesn't exist. There is just no way to prove beyond a shadow of a doubt any of the theories ==> afterall that's why they are called theories. However, at evolution, at least, has withstood thousands of scirentific studies, while chreationism has not withstood even one.

From Q&A
2. Isn't evolution just a theory that remains unproven?
In science, a theory is a rigorously tested statement of general principles that explains observable and recorded aspects of the world. A scientific theory therefore describes a higher level of understanding that ties "facts" together. A scientific theory stands until proven wrong -- it is never proven correct. The Darwinian theory of evolution has withstood the test of time and thousands of scientific experiments; nothing has disproved it since Darwin first proposed it more than 150 years ago. Indeed, many scientific advances, in a range of scientific disciplines including physics, geology, chemistry, and molecular biology, have supported, refined, and expanded evolutionary theory far beyond anything Darwin could have imagined.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

ok, this is what i am suppose to do word for word:

Create a function, GetStudents, which will receive the array and an int representing the count(2). In the function loop thru the data and get all three fields from the user using cin, cin.getline and cout statements. Organize like this: for (...........) { cout and cin.getline for name cout and cin for GPA cout and cin for Major cin.ignore(1); } The problem is that a cin for a numeric will leave the ENTER key in the keyboard buffer and that is OK with cin and other numbers but not with strings, thus we must remove it on our own.

and here is my code for student.

Student GetStudent(Student &s3)
{
     for( count = 0; count < 2; ++count)
     {
          cout << "please enter your name: " << endl;
          cin.ignore( 30, '\n' ) ;
          cin.getline(s3.Name, 30);
          cout << "Please enter your GPA: ";
           //cin.getline(GPA);
          cin >> s3.GPA ;
          cout << "Please enter your Major: ";
          cin >> s3.Major ;
      }

....and that is why i need to use a for loop.

I have already told you TWICE how to do that. Possibly you did not understand what I posted. Go back and re-read some of the previous posts that mention that function. THE PARAMETERS ARE INCORRECT AND YOU MUST CHANGE THEM.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you did not code the class constructor or destructor.

Opra_record() {}
    Opra_record(const Opra_record&);
    ~Opra_record() {}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Opra_record* rec; // = new Opra_record;
you misquoted that. remove the star. Its the difference between static allocation and dynamic allocation. The object is instantiated, and the constructor is called.

Your operator>> function requires a reference to a statically allocated object and you were attempting to pass a pointer. Doesn't work.

>>I changed the line that you had changed. Same error.
you did not change it correctly. it still has the star which is causing the problem.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

There was a short film on tv the other day on the history channel (I think) that discussed that. The interviewed a very old shepherd (maybe in his 80s) who had been born and raised on the area, and he also confirmed that it would have not been possible for Jesus to have been born in December. But I think most people are aware of that anyway -- someone just chose Dec 25 for some other reason. Its not the date that is important, but what we do on that date.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

JJ: Oh I think I understand now. Apparently Nintendo never had any kids play with the Wii before they put it on the market. If they had, they would have seen those straps break and the Wii fly across the room into TV sets etc.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Only 2 people who are married in this entire forum (I guess Miss Narue and Mr. Dragon).....heh

I thought I would get advice from the married pros but we seem to be lacking them here ;)

Probably because most posters here at DaniWeb are students -- and they have more important things to do right now than get married, such as school work.;)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The AC adapters are also being replaced because they overhead and could cause burns.

>>Have you seen any of the Wii adverts
No, but I'll make it a point to watch the next one.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

this compiles without error or warnings using my compiler which is not g++.

#include <fstream>
#include <vector>
using namespace std;

class Opra_record {
    friend std::ifstream& operator>>(std::ifstream&, Opra_record&);
private:
    std::vector<std::string> stringData;
    std::vector<long> numericData;
    std::string temp;
 
public:
    typedef std::vector<std::string>::size_type size_type;
    Opra_record() {}
    Opra_record(const Opra_record&);
    ~Opra_record() {}
    Opra_record(const std::vector<std::string>&);
    size_type size() const;
    std::string& operator[] (size_type i);
    const std::string& operator[] (size_type i) const;
 
};
 
std::ifstream& operator>>(std::ifstream& in, Opra_record& r)
{
	return in;
}
 
void parseFile(ifstream& in)
{
    string tmp;
    Opra_record rec;// = new Opra_record;
    while(!in.eof()) {
        in >> rec;                 ///***************here 
    }
}
 
int main(int argc, char** argv){
    if (argc < 2)
        return(EXIT_FAILURE);
    ifstream in(argv[1]);
    if(!in)
        return(EXIT_FAILURE);
    parseFile(in);
	return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Did you forget to include <fstream> ?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You need to pay more attention to detail, the variable names in the structure, and capitalization.
>>cin.getline(movie.title,string movietitle);
that is the incorrect use of getline. There are two versions of getline, one for C-style character arrays and the other for std::string objects. You used the wrong version

getline( cin, movie.movieTitle);

>>cout << "MovieDirector" director.name << endl;
that line is incorrect. Again, pay attention to detail, spelling and capitalization.

cout << "MovieDirector"<< movie.movieDirector << endl;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I get a kick out of reading people's signatures and find many of them funny and witty. Which ones do you like?

Here's one I just read :lol:

If a job is 10% inspiration and 90% perspiration, does that mean the job stinks?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Hmmm, not with you on this one. Many couples these days live together as if they were married for years, even buying a house and having children together. No one would call such people single, except in a strictly legal sense. Steven.

According to this common law fact sheet living together and/or having children together does not constitute a marriage. The couple must also present themselves to the public (friends etc) as a married couple, using the same last names, filing joint tax returns, etc. I have no idea how it works in other countries.

I think marrige means less in terms of someone's place in society than it used to. For a woman to bear a child out of wedlock (in England) used to be the height of scandal only a hundred years ago. Now its a matter of personal choice.

Same here. about half or more of the babies are born to single mothers and many to mothers who are themselves children. babies having babies is a common expression.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

But I'm most defenitly not single. :)

Niek

definition: single: never been married. shacking up with someone doesn't constitute marriage in most places. So, you are either single, married, divorced or windowed. There are no other categories:cheesy:

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

never used one so I have no idea. So a strap breaks, so what? what happens? do you get electricuted or something?

>>breaking and it slipping out of their hands, causing damage to TV's, windows, lights and people, amongst others

Ok, lets say you are holding one of those little monsters and the strap breaks. How in the world could it possible damage a TV, window etc. etc. ? When it hits the floor does it explode like a stick of dynamite?

As for Nintendo -- they should be ashamed of themseves selling a product that can so easily be broken.
>>they say that if used correctly the straps are not prone to these sorts of breakages
Sorry Nintendo, we a PEOPLE, not robots, and people do not always do things they way they should.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I get hundreds of spam every day. First I move everything to junk mail folder, sort by address then move the mail back to inbox only those whose addresses I recognize. All others get deleted without opening them. e-mail from well-known companies such as AOL, Microsoft, etc that I did not request also get ignored.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

she looks great! I see everything double like that. :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

EST is GMT - 5. So if you know what time zone your program is running in then adjust accordingly. use gmtime() then subtract 5 hours for eastern.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Your coding style is really quite terrible. There is nothing wrong with putting stuff on separate lines to make it easier to read. Easy reading is much better than being cute. For example:

for(int r = 1; r <= rows; r++)
   {
<snip>
   for(b = 1; b <= rows; b++){
      if(best < maxsum[rows][b]) best = maxsum[rows][b];
      cout << "it works here: fourth for loop: iter:"<<b<<" ";
      }}

would be much better something like this. The coding style below makes it immediately clear where the beginning and ending of the blocks are located -- it is not necessary for the programmer to hunt all over the file for the matching braces.

Putting two braces on the same line like you did just looks very sloppy coding.

for(int r = 1; r <= rows; r++)
   {
        for(b = 1; b <= rows; b++)
       { 
            if(best < maxsum[rows][b]) 
               best = maxsum[rows][b];
             cout << "it works here: fourth for loop: iter:"<<b<<" ";
        }
     }

I this this is a correction

#include <iostream>
#include <fstream>
using namespace std;

int main()
{
   int num, rows;
   unsigned int maxsum[200][200] = {0};
   int best = 0;
    //cout << "it works here: definitions ";
   ifstream infile("INPUT.TXT");
   ofstream outfile("OUTPUT.TXT");
    //cout << "it works here: filestreams ";
   infile >> rows;
   //cout << "it works here: infilestream rows ";
   for(int b = 0; b < 200; b++)
   {
		//maxsum[0][b] = 0;
		//cout << "it works here: first for loop: iter:" << b<<" \n";
		for(int r = 1; r …
SpS commented: Right: SunnyPalSingh +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>cout << "<input type="text" name="firstname"> " << endl;
That line is ill-formed. count the quotes and you will find that the word text is NOT within quotes.
This is probably what you want

cout << "<input type=" << text << " name=" << firstname << "> " << endl;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

cppreference doesn't list structure as a key word in either C or C++. Is it really a keyword?

no it is not. where did you see cppreference ? there is a www.cppreference.com web site.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>#include <sstream>
that should be <strstream>

but since you are not using it in your program you can savely just delete that line.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

did you try their web site?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what operating system? There are no standard C or C++ functions to do that. If you are using MS-Windows you can call the win32 api function GetTimeZoneInformation()

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

have you tried to compile that program? what are the compiler errors?

tructure Moviedata;

int movie title;
int movie director;
int year released;

That is not the correct way to declare a structure. Here is how it should be done. Since you are writing a c++ program you should use std::string instead of char arrays.

structure Moviedata
{
   string movieTitle;
   string movieDirector;
   int yearReleased;
};

Here is some of the program to get you started on the right track.

#include <iostream>
#include <string>
#include <sstream>
using namespace std;


structure Moviedata
{
   string movieTitle;
   string movieDirector;
   int yearReleased;
};

int main()
{
   // declare an object of type struct MovieData
   structure Moviedata data;
   // display a prompt
   cout << “Enter the movie title “;
   // get movie title from keyboard
   getline(cin,data.movieTitle);


   return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes -- I get to hear that thing from a lot many elders out here..Looks like you really are ancient Mr. Dragon.

Apparently that is a universal trueism. :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Isn't this leaking memory (aside from the fact that no attempt is made to delete the lost memory)?

yes it is -- I hadn't noticed that error.:o

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It could be very possible that neither evolution nor creationists theory are correct. Neither can be fully proven because its impossible for us to see back to the beginning of time. Its all nothing more than speculation. But I'm more likely to believe evolution then the creationists theory. There have been several films on TV about this and the Big Bang theory in recent weeks. All theories and good special effects in the films, but no observable facts.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

here is a simple example, but it is not in C language. If you study some of the google links you will find other examples that might help you

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

c program to find largest number in an array

what about it? have you tried to do this? If you have, then post your code so that people here can help you with your questions.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If yes then what did marriage change in your life, are the new found responsibilities burdening you or making you a better person ?

Regards,
~s.o.s~

PS: I am single and for me marriage is a sacred relationship...

I have been married (to the same woman) 43 years next July. I can't really recall when I wasn't married.:) She was my high-scool sweetheart.

Of course no marriage is perfect, and we had our ups and downs just like many others. I think the trick to a long and reasonably happy marriage is to never go to bed mad at your partner. whatever disagreements you may have had during the day should be resolved before then. Marriage is a partnership, men can not treat their wives as slaves and baby factories. The days of "keep her bear foot in the winter and pregnant in the summer" is no longer relevent, at least not where I come from.

christina>you commented: sooo sweet!! +15
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

have you read this?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You would need to convert the binary number to an integer first for that though, wouldn't you?

binary numbers are either signed or unsigned integers. No conversion necessary.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

create a loop that repeatedly divides the value by 10 until its value becomes 0. increment a counter on each loop iteration. see the description for the idiv instruction if you do not know what it does.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

is it possible to install them both ie iis the application server and oracle's database server on the same computer?

Yes, and that is frequently done. MS-Windows and *nix can do both. But if the traffic or database requires are high enough you would want to put them on different computers so that they can process the information more efficiently.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

or this, which is almost identical to what ~S.O.S.~ posted. Like most things in programming there is always more than one way to do it. Unless you are instructed to do otherwise you can choose whichever method you want. One is not any better than the other unless you make the buffer too small to hold the result. In that case neither version will work correctly.

#include <iostream>
#include <ctime>
using namespace std ;
 
int main( )
{
    char buffer[BUFSIZ] = { '\0' } ;
    time_t now = time( &now ) ;
    struct tm* local_time = new tm( ) ;
    local_time = localtime( &now ) ;
    sprintf(buffer,"%02d/%02d/%04d",
          local_time->tm_mday,
          local_time->tm_mon+1,
          local_time->tm->year+1900); 
    cout << buffer ;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I think Dev-C++ will be easier for beginners to learn the language because it doesn't have as complex an IDE as MSVC. Once you get to the place when you want to start writing MS-Windows gui programs then you should probably switch to the Microsoft VC++ 2005.