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

VB will teach you a lot of things that are common to nearly all languages, such as data types (integers, strings etc), loops, and file systems. So pay close attention to what you are learning because they will be valuable later on. My recommendation is to begin learning c++. You can get a good list of recommended books in the Read Me threads at the top of this c++ board.

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

you need to read the description for fork()

On success, the PID of the child process is returned in
the parent's thread of execution, and a 0 is returned in
the child's thread of execution. On failure, a -1 will be
returned in the parent's context, no child process will be
created, and errno will be set appropriately.

The second program you posted never checks for existance of the child so it just continues to create children of children etc. My guess is that when i == 0 the program will create 9 * 8* 7 * 6 ... *1, or 9! children.

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

compulsary military service = draft :)

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

You should uninstall VC++ 2005 Express and get VC++ 2008 Express. Microsoft fixed several things that was a thorn in everyone's side with the 2005 IDE.

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

Does it matter if it is or isn't. I think the last paragraph has a damn good point.

Absolutely true. I've known a few people to hate themselv and make everyone around them miserable too. I refuse to live like that and left home at age 19 because of it. Not saying I was perfect either but tried not to make other people's lives miserable just because mine isn't perfect.

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

I beg to differ -- how many murders, rapists, and drug pushers would you expect to find in heaven ?

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

Ohhhhhhh! I have to buy that for my auto CD player :) :) :)

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

Hi! Glad to meet you and welcome to DaniWeb.

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

I agree, sailing enthusiast should not end up in hell!

Depends on what else he did during his life. For example do you know if he ever stopped beating his wife ?

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

>>Whats the use of a NULL pointer ?? Won't null pointer assign value 0 to the pointer
That's correct. It initializes a pointer to a known value which can not be used for anything. Its useful for testing pointers to see if they are valid. Programmers make many mistakes by attempting to use uninitialized pointers and setting them to NULL makes it easy to check that.

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

Dave: I agree with that link. What I had in mind was that each array dimension is allocated dynamically instead of statically.

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

what code do you want to write? what compiler and operating system do you have ? There are lots of tutorials and books about how to get started. See some of the Read Me threads at the beginning of this c++ board for a lot of other help.

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

**p can be either 1) a pointer to a pointer, or 2) a two dimensional array. Compile and run the below, maybe it will clear it up a bit.

void foo( char **p )
{
    // allocate some memory
    *p = new char(8);
    // copy something to it
    strcpy(*p, "Hello");

}

int main()
{
    char *ptr = NULL; // simple pointer
    foo(&ptr);
    cout << ptr << "\n";
    return 0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

From what I read in those links looks like I was wrong. Should have used memmov() instead of strcpy().

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

This has gotton off-topic so I decided to split it into its own thread.

str is a character array that is located somewhere in memory, exactly where we don't know nor do we really care. We let the compiler and the operating system figure that one out because the exact location can change from one run of the program to another.

But for the sake of arguments lets assume that the beginning of the character array named str is at address location 500. Then if you set a pointer p to point to str[2] then the address stored in the p variable will be 500+2 or 502.

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

You might read this tutorial. Although mostly tecnically accurate you can ignore some of the more technical comments until you understand pointers better. Concentrate on the illustrations that tutorial presents.

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

You have to change the registry. create a command prompt then run regedit.exe.
expand HKEY_CLASSES_ROT then scroll down until you find .cpp folder. delete it as you would any other folder in windows explorer. Do the same with .c and .h. Then exit regedit.

Next open Windows Explorer and double click on any *.cpp file. This will bring up a dialog that asks you which program you want to use to run that file. I was given the option of either Dev-C++ or VC++. I chose VC++ and it was launched. Close VC++. Now every time you use Explorer and click a c++ file the os will launch VC++ without further prompting. You can do the same with *.c and *.h files if you wish.

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

depends on the context. *ptr refers to the byte at the address stored in the variable named ptr. When you get an error like can't covert int* to int it means that something was expecting a pointer and you passed only an integer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
for(i=0;str[i]!='\0';i++)
{
len++;
}

you could optimize that loop like this:

for(len = 0; str[len] != 0; len++)
   ;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

lets assume we start with this: char str[] = "SACRED"; Now create two pointers (you need to know about pointers for this to make any sense to you).

// pointer to destination string
char* p1 = &str[2];
// pointer to source string 
char *p2 = &str[3];

// while not end of string
while( *p2 != 0)
{
   // copy one character from source string to destination string
   *p1 = *p2;
   // increment destination string
   ++p1;
   // increment source string
   **p2;
} // end of while statement
*p1 = 0; // null-terminate the destination string.

At the end of the first iteration of the above loop the string will be "SARRED"
second iteration: "SAREED"
third: "SAREDD"
last: "SARED" // only the null terminator was copied

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

Not a typo. the & symbol in that statement returns the address of the memory at that location. &str[0] is the address of the first byte of the character array, so &strp[2] is the address of the third byte.

strcpy() function requires two parameters, a pointer (or the address of) to the beginning of the destination buffer and a pointer to the source buffer. In the statement I posted it is going to delete the 3d character by shifting all the remaining characters left one character.

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

I'd hate to be hit by a maglev shuttle.....

You'd never know what hit you and there would be no mess to clean up because there would be nothing left of you to find :) But I wonder what they will do about wild animals getting on the tracks ?

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

Mass transit doesn't work, unless a lot of people want to make the same trips. In a city like mine, there are so many different possible trips that mass transit to cover even a tenth of them is prohibitively expensive.

St Louis began a mass transit rail system about 10 years ago and was an immediate hit. The trains are always full and there is a train going by each rail station every 15 minutes. When there is a baseball game at the down-town St Louis Cardinals Bush statium (no relation to our president) there is a train every 5 minutes. And the city continues to expand the system every few years with the overwhelming taxpayer support.

And its inexpensive too. The last time I rode it I could go anywhere I wanted for only $1.50USD. The St Louis airport is about an hour's drive from my home. Now I just drive to the nearest station's free paring lot, about 10 minutes away, and take the train.

And environmentally safe I think (electric engines).

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

>>I get an bunch of linker errors like "duplicate symbol X found..." which are for symbols from b.h

That indicates there are errors in the header files -- you are compiling the *.cpp files correctly. Post the header file, you probably have an object declared in it without the extern keyword.

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

Undefined behavior.

Source and destination strings do not overlap, they are simply in the same buffer, so where's the undefined behavior?

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

>>now that is brave.
I'd call it stupid :) McCain and Bush are too much alike, which is why I think the democrats will win by a largest lanslide in american history this November.

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

Army sucks. Go Air Force :) (I'm retired US Air Force if you hadn't already guessed)

Manditory military service is good for the soul and for what ails you. Joining a military will make a man out of you. Every young man ages 18-25 should experience at least two years in the military because you will be a better person when your time is up.

We don't have a manditory military service any more and voluntary service has worked pretty well for the country, but can't say the same for the millions of men who never spent one day in the military.

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

Seems like quite a large program. I would tackle it by dividing it into smaller portions. At the start do only the minimal amount needed to get the program going, such as create a student structure that contains the student information needed, such as name, matrix number, and a linked list of subjects.

Next step is to write a menu for the required operations, such as add, delete, etc. Once you get that working ok you can begin coding those functions. Code a function, compile, test and fix any errors. Repeat that for each of the functions.

The last thing to do is implement the requirements listed at the end of the problem description.

Happy programming, and come back with code when you have problems.

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

>>Does the file pointer discard the newline character after COMETQ ?
Yes. So only 7 are required in his program. This is unlike C's fgets() where the new-line, when present in the input stream, is appended to the end of the string if there is enough room in the input buffer.

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

depends on whether vehicle_Detals derived from People as public or private

class People
{
   // blabla
};

class vehicle_Detals : public People
{
   // blabla
};

class Visitor : public vehicle_Detals
{
  // blabla
};

In the above Visitor has the same assess to People as vehicle_Details has, in otherwords it has access to all public and protected data, but does not have access to private data.

class People
{
   // blabla
};

class vehicle_Detals : private People
{
   // blabla
};

class Visitor : public vehicle_Detals
{
  // blabla
};

In the above, Visitor does not have access to anything in People

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

Well, he liked sailing, so he had at least one redeeming feature. He is now sailing somewhere up there in the clouds.

On the otherhand he might be in the depts of hell. Its hard to tell where he went, if anyplace. I would suspect he was an athiest.

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

you could check the success/failure of the open

ofstream fout ("ride.out");
if( !fout.is_open())
{
   cout << "Failed\n";
   return 1;
}

[edit]commet and group buffers are too small. You didn't leave room the the null teriminator byte.

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

line 13 and 15 are backwards. You have to open the file before you can use it for anything. Switch those two lines around.

Next, you need to use brackets { and } to encluse all the code you want to be executed within that while statement. Without the brackets only the first statement immediately following the while statement will get executed.

The purpose of a while statement is to avoid the repetion that you have in your code, such as lines 20, 21 and 23, 24 and 26,27 and 29, 30. You can replace all those with just one set within the loop.

As for the infile.eof() -- I don't know why your teacher is stupid enough to require you to use it because it doesn't work the way most people would think. eof() is not even needed in your program.

cout << fixed << showpoint;
cout << setprecision(2);
while( ticketSale >> num1 >> num2 )
{
cout << "Ticket Price: $ " << num1 << " Tickets Sold: " << num2 << "   Profit: $ " << num1*num2 << endl;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

std::ios::fixed Just add the std:: in front

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

Didn't you even bother to read Walt's comment just above yours ????

>>Does anyone has another solution?
Yes -- you have at least a couple of options

  • Rewrite the code using Win32 api functions
  • Use a different compiler such as Dev-C++
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> the royal family suck, but the queen is ok
The royal family is probably (and I don't mean this offensively, just stating facts), the most inbred family in the UK.

I think football (UK soccer), is stupid and boring. You watch it for an hour and a half and unless you're fortunate no more than about two goals are scored. I was glued to the TV when I was watching the SuperBowl. Though you know what they say about new things, I suppose.

Baseball is the same -- they can go the entire nine innings without scoring one point.

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

Per capita the Brits have 0.21 universities per million and the Yanks only have 0.12 universities per million inhabitants in the top 100.

Also, the Brits have a Queen and we have nothing!

Hallelujah!!

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

Must be a local jockey. I never heard of him either.

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

How? They're not even playing the same game.

How? in terms that UK football (socker) is more interesting to watch.

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

>> Define 'American Accent', please.
"Like, oh my Gawd".

That's not an accent, any more than "I'll knock you up". In USA that means you are going to get someone pregnant while in UK it just means you are going to knock on someone's door.

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

In terms of education, healthcare etc I don't think anyone can really have an educated view on this unless they lived in both nations for long enough period, say about ten years..

A comparison of educational institutions (universities) around the works shows USA far ahead of any other nation including UK. The top 100 universities in the world contains Harvard (USA) in the #1 spot and Cambridge (UK) in #2 spot. USA has 37 universities in the top 100, while UK has 13 (if I counted correctly).

US football vs UK football -- UK wins.

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

You need to post what you are attempting to do because its a little difficult for us to see your computer screen :) But I suspect you are asking about character arrays insterad of c++ strings.

If that's the case, there are a couple ways to do it. One way is to use strcpy() function

char str[] = "SACRED";
strcpy( &str[2], &str[3]);

I didn't compile or test that, but I think it will work.

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

I didn't like him either -- he was a real big stuffed shirt, more IQ then he knew what to do with. He came from privledged elete and was never hesitant to let everyone know it.

RIP Buckley.

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

I don't care much for wine, but I'll drink it if I have to :) I absolutely hate whiskeys and burbones. My favorite is Black Russians, vidka and gin. But, alas, I can't drink any of that any more ***sigh***

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

in ie7 hit a key (i think its either control or alt) and the classic File-Edit-View-Tools-Help menu comes down

Oh yes you're right :) Thanks for that.

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

Helcome to DaniWeb. I hope your name isn't catching :)

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

Ah.. you Americans always have to have it bigger. Cars .. meals .. earthquakes ..

Not really -- there are places around the world that have bad things happen a lot worse then we have -- we have a few hurricanes on the east coast, earthquakes on the west coast and tornadoes in the midwest (where I live). I'll bet India gets hit with bad weather a lot worse than we do. Only had one valcano explode in the 48 states in my lifetime that I recall (hawaii has them often).

Cars -- yes they're bigger and they guzzle a lot more petro too

meals -- they are probably bigger which is why we are fatter. If there is ever a world-wide famine we will be the only people on earth who will survive.

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

Here is one way to convert the string to an integer

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

int main()
{
    string input;
    cout << "Enter a hex value ...";
    cin >> input;
    cout << "\n";
    stringstream s;
    s << hex << input;
    int x;
    s >> x;
    cout << "x = " << x << "\n";
    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

forget exam1 and exam2. What you have in that structure is an array of exam grades. If you want the list of grades you posted in your post #28

stu.examcode.push_back(3);
stu.examcode.push_back(13);
stu.examcode.push_back(34);
... // etc etc for the complete list.

Now if you want to check if exam1 and exam2 are in the list above

for(int i = 0; i < stu.examcode.size(); i++)
{
     if( stu.examcode[i] == exam1 || stu.examcode[i] == exam2)
     {
              // found it so now do something
     }
}