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

Here you go, now all you have to do is fill in the missing parts

#include <string>

class Student
{
   // your code goes here
};

int main(int argc, char* argv[])
{
   // your code goes here
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It's not that I know more than you, which may or may not be correct. But I've been here longer, answered more posts, and have been involved in more closed threads. 15 days ago I asked Dani to reduce my rep power because I thought it was just excessive, which she has since done.

Dani has also implemented a voting system where everyone has just one vote per post. My vote counts no more or less than yours. When I give someone rep I also cast one vote. But I can vote without giving rep.

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

>>so i decided that i'm fed up of VC++. It was throwing me lots of stupid errors.
LMAO :) :) The errors are reported for a purpose -- because you wrote a buggy program. There are some warnings about depreciated standard C functions, but you can easily disable those warnings so that they do not appear.

The only compiler I have been able to get Code::Blocks to work with is MiniGW.

Rashakil Fol commented: lololol +6
pspwxp fan commented: tnx :) +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

plz help me 2 finish my c++ proj on supermarket.i need the exact details of the funcns,sub calculatns.............
urgent

How urgent is this? Deposit $100,000 USD into my paypal account and I'll help you out.

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

First you have to find out where tv.lib is located on your computer then tell your compiler. How to do that will depend on the compiler you are using.

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

Technology and lack of physical exercise are the biggest contributors to why Americans are so fat. Just watch Biggest Loser and you will see men and women who weight 400+ lbs! Americans are so fat because they sit on their ass so much watching tv or playing on their computers. Kids today would rather sit by themselves for hours playing video games instead of outside socializing with other kids their own ages. And that makes them social misfits when they grow up.

Vineeth K commented: I think you are right +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You don't because that compiler is too old.

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

>>The problem is that i cant select which one.
Whether Visual C or JAVA or python ..

"Visual C" is not a language -- its just the name of a compiler. You can use it to compile both C and C++ programs.

Why do you have to choose just one of those languages. Learn them all. If you have a good basic understanding of C language then learning Java and phython should be a snap because they all have a lot of things in common that you already know. But don't be like the "jack of all trades" ... know a little bit of everything but a master of none.

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

you forgot to initialize temp->next = NULL; at between lines 28 and 29, so at line 37 it can not find the last node.

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

>>don't forget to put a space after the back slash otherwise it will be an invalid character.

No, that doesn't fix it. You have to put two \\ if you want one in the text, such as system("copy MagsG.exe C:\\"); The space has nothing to do with fixing the error.

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

If you dual-boot Vista and Fedora or Ubuntu then Thunderbird email client can use a common email box for both operating systems. If you already have an email account set up on one of the operating systems, such as Vista, then open Thunderbird, select Tools --> Account Settings, then click the Local Folders link on the left side of the screen. On the right side you will see the current location of the email files under Local Directory. Write that down someplace so that you can reference it while booted in Fedora.

Now close Vista and boot to Fedora (or Ubuntu). While in that os, install Thunderbird if it has not already been installed (use Add/Remove Programs to do this), then set up your email account. After that is installed, again open Thunderbird, select Tools --> Account Settings, click the Local Folders tab, then use the Browse button to navigate to the same folder that is used in Vista.

That's all there is to it :) Now you can use all the same email messages in both operating systems. When new mail arrives it will be seen by Thunderbird in both operating systems.

majestic0110 commented: Nice ! +6
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>printf("%s",(char*)ch);

I've told you about that before in another thread. %s says the next argument is a character array, but all you are passing is a single character. What you should use is "%c", then remove that damned typecast.

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

you have to overload the << operator

class MyClass
{
public:
   friend ofstream& operator<<(const ofstream& out, const MyClass& str);
..
...
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

replace those tabs with setw() as shown in previous post. If you want the text left-justified (meaning, padded with spaces on the right side of the text) then also add left]/b]

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

int main()
{
    cout << left << setw(10) << "Hello"
        << left << setw(8) << "World\n";
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you use it the same way that you use any other standard library. Take time.h for example. That header file contains function prototypes for functions such as time(). Then all you do is call time(), passing the appropriate parameter. When you compile the program the compiler will link with the standard library that contains the source code for the time function.

You do that too. If you have a header file for that dll then include it in your program. If not, then just add the function prototypes to the top of your program, after all other include statements. Then all you have to do is call the function just like you would have called time() in the above example.

You have to tell your compiler the name of the *.lib file. I don't have Code::Blocks installed so I can't tell you how to do that, but I'm sure it should be fairly easy to find out by browsing around the program's project options.

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

OMG! Only 16!:icon_eek: Computers had not even been invented yet when I was your age -- I was more interested in girls.

Anyway -- glad you are here ;)

tux4life commented: True. +18
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Try this. GetNext() simply returns NULL and that is not what you want.

void Lobby::AddPlayer()
{
    //create a new player node
    cout << "Please enter the name of the new player: ";
    string name;
    cin >> name;
    Player* pNewPlayer = new Player(name);

    //if list is empty, make head of list this new player
    if (m_pHead == 0)
    {
        m_pHead = pNewPlayer;
        m_pTail = m_pHead; //m_pHead->GetNext();
    }
    //otherwise find the end of the list and add the player there
    else
    {
        m_pTail->SetNext(pNewPlayer);
         m_pTail = pNewPlayer;
         //m_pTail = m_pTail->GetNext();                   
                                        
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Today my wife and I have been married (to each other :)) for 47 years. Going to wine and dine this evening so you won't see me around for the rest of today.

kvprajapati commented: The Great man. +7
jephthah commented: belated congrats! +14
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

AD: *t = _totoupper(*s); I don't know that function, please tell me about it :P

See the link in my post #4

tux4life commented: Yes, but they don't mention _totOupper, only: _totupper :P +15
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Just a guess, but if you are trying to read the contents of a structure perhaps there are holes in the structure, such as the packing factor is something other than 1.

#pragma pack(1)
struct mystuff
{
   WORD a;
    DWORD b;
   // etc
};
#pragma pack()
Intrade commented: Expert analysis +1
Salem commented: *nods* +35
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I was wrong only once in my life -- I thought I was wrong but I was wrong. -- Unknown

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

>>for example if I enter the file name as "1234567" (only digits), It should create "0001234567_OP.txt"

#include <sstring>
#include <string>
#include <fstream>
using namespace std;

int main()
{
    int num = 12345;
    string filename;
    stringstream str;
    str << num; // converts num to a string
    filename = "000";
    filename += str.str();
    filename += "_OP.txt"";

   ofstream out(filename.c_str());
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Do you also manufacture your own automobile? Grow your own food? Milk your own cow? Build your own house? You didn't write wcslen() so why be so inconsistent. When you write all that yourself you just have lots more code that introduces bugs you have to fix, like this one.

iamthwee commented: 'Milk your own cow' - don't EVER call her that, she'll slap you. +21
tux4life commented: Excellent! +7
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Since you didn't care to express your opinion in a decent post, allow me to copy it for you, so I can make a reference to it.

What do you mean by "I rarely give bad rep except here"?
What prompts you to give a bad rep here?
Why is important for you to make a distinction between "here" and "over there", I suppose?

What's the result or effect you expect to achieve by giving a bad rep here?
And lastly, if you don't mind; why do you choose such a very limited form of expression to show disapproval, when it is so prompted to misunderstanding and there's not provision for rebuttal nor dialog?

Rep here in Geeks' Lounge means nothing at all, it doesn't affect your overall rep points. All it does is put a yellow or green dot on the post. Those of us who have high rep counts need to be a lot more judicious about when to give bad rep (in the other forums) because we could easily destroy someone's rep count which would be very difficult for him to recover. Anywhere except here in the Community Center I will normally make a post explaining my disagreement instead of giving bad rep. I'm a little more liberal with giving out good rep when the member deserves it.

To be honest the only reason I gave you bad rep in this thread because you were complaining about the rep system. Had you complained …

iamthwee commented: Amen +20
tux4life commented: Good clarification about the rep system :) +8
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

We have a lot of ghosts here in St Louis -- they even vote every election year :)

Ezzaral commented: heh! +22
ahihihi... commented: Sumimasen.. NYAHAHA! +1
amrith92 commented: Ghost Voters: whatever next! :) +1
scru commented: haha +6
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Are you sure that this program compiles? You seem to have used string in your code, but you haven't included <string.h> at all...!

That's because std::string is not declared in <string.h> -- its in <string> header file. And some compiler include <string> with <fstream>

tux4life commented: Correct! +6
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

And a Dr. Pepper can will emit vibration if you squeeze it. The crinkling aluminum produces the vibration of sound waves.

My wife does that too :)

ddanbe commented: Long time ago I had such a laugh! +5
Aia commented: A complete show of lack of class. -3
tux4life commented: :D +7
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

who or what is libJudy? (don't tell me its a library because I already guessed that :) )

Salem commented: libJudy implements a "Judge" method ;) +31
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The code you posted is slightly different than the code in the origina post in that this new version returns a complete vector, not just a pointer. When CreateHandle() returns the compiler will duplicate the entire vector before leaving the function, then duplicate it all over again on line 16 for vector menu. For large vectors that can be very very time consuming which would not be acceptable in any professional program.

There are two alternatives:
1) make the vector static so that its contents are never ever destroyed until the program itself exists, then return a pointer to it.

2) pass it by reference as I previously mentioned.

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

I give up. Read post #14 again.

William Hemsworth commented: Hang in there :) +10
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

How do i open the file?

inFile.open(str); Note that scanf() will not allow spaces in the text, so if the filename and/or path contains spaces then you need to use getline() instead of scanf().

tux4life commented: I didn't think of that, but it's absolutely right ! +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Everyone gets bad rep from time-to-time, don't worry about it. Feel lucky I didn't give that bad rep because it would have cost you 23 points instead of the 4 points Killer_Typo gave you.

~s.o.s~ commented: Is this a threat or wut? :-) +28
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You could create an array of pointers

class Holding
{
   // blabla
};
class Derived :public Holding
{
  // blabla
};

Holding **array = new Holding*[size];
// add a class of type derived
Derived* dv = new Derived;
array[0] = dv;
BestJewSinceJC commented: patient, multiple solutions... +5
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Sounds like you need to post in Job Offers -- someone might help you if you want to pay $$$ for their work.

nexocentric commented: So right! So right! I'm volunteering though..... +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

[sarcasm]Ha Ha[/sarcasm] -- moved to Geek's Lounge because your post was not an introduction.

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

Try something like this:

char filename[20];
if(argc>1)
{
    filename = argv[1];
}

In your example you have to use strcpy() strcpy(filename, argv[1]);

tux4life commented: Everyone makes mistakes :) +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't know about gcc, but Microsoft compilers have an optimize pragma.. You might check of gcc has similar pragma. There is no similar pragma for _root that works on individual variables.

You might also try the volatile keyword.

Salem commented: volatile seems like a good match +30
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Just thought I'd let you know why misspelled words are not caught while you type today.

Nick Evan commented: http://www.extremefunnyhumor.com/pics/Google_Usage.jpg +17
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

But my C++ Book says so, by the way, why are we otherwise checking whether an assignment has failed or not using if(ptr == NULL) ?

You misunderstood your book. Better read it again. Maybe the book is talking about smart pointers

tux4life commented: You were right, actually I don't have to doubt about what you say: You're just *always* right :) +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Does curl involve WinApi (like i believe winsock does, or at least it seems that way) ?

Probably, but its transparent to us programmers because its cross-platform. It uses the api from whatever platform we want to use it on.

I am having huge trouble finding my way around the WinApi :/

Join the party :) We all have problems with it because it is so huge.

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

>>im waiting for your reply
I'm not going to write it for you. YOU write the code and we will halp with whatever questions you may have. But the code you turn in must be your own, not ours or mine.

tux4life commented: Well said :) +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is a tutorial that actually compiles, links and works. It's possible that book you are reading is just too old.

ShadowScripter commented: Already tried it, but at least you were willing to help out, maybe in time I'll see what stupid mistake I did. Thanks! +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you could write a copy function to avoid the duplicate code you have

char* copy(char* to, char* from)
{
   while(*from)
     *to++ = *from++;
   *to = 0;
   return to;
}
char* cat(const char *arg1,const char *arg2)
{
    char *p = new char[strlen(arg1)+strlen(arg2)+1];
    copy( copy(p, arg1), arg2);
    return p;
}
Sky Diploma commented: Thanks-- That Really Helped. +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>pow(+1.0, n+1)/pow(n*n,2.0);
How does (1/9) translate to the above equation? When n = 1, the above will be pow(1,2) / pow(1,2) which is 1^2/1^2 = 1. When n = 2, we get pow(1,3)/pow(4,2) which is 1/16

It looks to me your formula is completely wrong. How you get from (1/9) to (1/25) I don't know, but it doesn't work that that formula or program.

Another point about that equation -- pow(1.0, n+1) -- the result will always be 1 so the formula boils down to 1/pow(n*n,2.0)

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

Isnt that an elvis or a jonny cash song or something? "boy named sue?"

Johnny Cash

Salem commented: The US has Jonnny Cash, Bob Hope and Stevie Wonder. The UK has no cash, no hope, and no bloody wonder! +29
jephthah commented: awesome +8
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The U.S. Census Bureau statistics tell us that there are at least 88,799 different last names and 5,163 different first names in common use in the United States. Some names are more common than others.

There are 50,582 people named John Smith in the United States. There are 1,070 people named James Bond, 115 people named Harry Potter , 514 people named George Bush, and 32 people named Emily Dickinson. However, Johnny Cash (39 people) songs aside there are, statistically speaking, very few boys named Sue.

http://ww2.howmanyofme.com/

Naming your son Sue would definitely be child abuse :)

Nick Evan commented: Cash: The real king of rock 'n roll :) +16
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No one gets rep points good or bad here in Community Center Forum. Only get the colored dot on the post; does not affect overall rep points.

WaltP commented: Good answer!!!! :- +17
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I'm only new to C++ and need urgent help with an assignment that's due tomorrow.
Procrastinating did you :) You can not leave programming assignments until the last minute, if you do you will fail the course. Programming takes lots and lots of time and effort.

Do the program one small piece at a time. Get the first part working then go on to do the next part. For example, your first task is to write a program to get the last name and sir name from keyboard. Use cout to display prompts and cin to get user keyboard input. You will need two strings, one for sirname and the other for lastname.

tux4life commented: Very good reply :) !! +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>1) How could time (in the form of HH: SS above) be represented in the array, so >>that they can be subtracted? How do you subtract when

Don't put the dates/times in an array at all.

Convert the time read from each line into seconds, then all you have to do is subtract the seconds. Something similar to time_t variables.

One way to do that is to populate a struct tm structure with the date/time, then call mktime() to get the time_t object. You will have to parse the line read from the file
Example:

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

int main()
{
    struct tm time;
    time_t t1, t2, t3;
    char c;

    // populate first time
    std::string t = "2008/11/22 14:59"; // assume this is read from file
    stringstream str(t);
    memset(&time, 0, sizeof(struct tm));
    str >> time.tm_year >> c; // get year and / character
    str >> time.tm_mon >> c;
    str >> time.tm_mday;
    str >> time.tm_hour >> c;
    str >> time.tm_min >> c;
    // subtract 1 from month so that it is between 0 and 11
    time.tm_mon -= 1; 
    // substract 1900 from year
    time.tm_year -= 1900;
    t1 = mktime(&time);

// now to the same with the other times t2 and t3
}
tux4life commented: You're always great in simplifying things :) +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what don't you understand about those problems?

Q1: once you know what Pythagorean triples are then the rest is not difficult. Try to write the program yourself, and post the code you have written if you still can not solve the problem.

If you was able to do Q4 then you should be able to do the others, because I think Q4 is more difficult than the others.

tux4life commented: Oh, I didn't know it is called a 'Pythagorean triple' in English :) +2