WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Here's what I'd do:

Start over.
Step 1) Read that link I posted.

Step 2) Read the data into the arrays. As soon as you put a line into the array, write the array entry to the screen. Think about the loop and when it should end. Refer to Step 1.

When done reading:

Step 3) In a loop display the entire contents of the arrays. Make sure things were read in and stored properly.

When all that works completely, continue to the next step.

It will also help greatly if you format your code better.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I already answered this in the other thread in which you asked the same question.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

@waltp ok what should i do ?

Just ask a sensible question without all the emotion. Give details about what you want. Explain what it is you don't understand, and what you do understand.

u must tell me :'(

No, I don't have to tell you. But I did anyway ;o)

Here's you post:

I request every body on DAniweb.com that please ,

Requesting everyone??? Most of us haven't a clue what you're talking about. Why would you want them to respond?

if any body knows about segment tree, then please either explain me it's update, making otherwise give me solid links so that i can learn from there.

Try google. That all we're going to do anyway. And we'll just post the links we've found.

IT'S REALLY PATHETIC SITUATION AS I AM NOT GETTING THIS FROM WEEKS. PLEASE IT'S A REQUEST TO ALL. :'(

DON'T YELL AT US!!!! And when we see something like this, it tells us "I'm so pathetic! I can't even understand one thing!". Our response: "Yes you must be. Go do something else -- like neurosurgery instead."

Why can't you have your instructor explain this stuff to you?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

1) Dice is the plural. Dices is chopping vegetables into small cubes.

2) Reread your information about srand(). Is it supposed to be where you have it?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

bookTitle[SIZE]

Every time you specify bookTitle[SIZE] you are specifying the memory just past your bookTitle array. Haven't you been taught about array indecies yet?

while (!filePath.eof()){ -- See this

for(i = 0; i < count; i++){ -- Do you actually know the value of count?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

ok guys there is another problem:-

OK guy, here our problem.

You won't respond to our questions, just post new questions.
You don't give us any indication that out help was useful. All you did was complain about our answers.
For all we know you dropped the original question because it was too hard and we wouldn't write it for you.

Why should we waste our time on new questions?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

read-icon-small Here's an icon that can be placed next to the RSS.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Can another Mark link be added to the top next to the RSS icon? It's rare many of us scroll below half a page.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Start over. I can't understand what you're doing at all. I've never seen such a complicated fibo program in my life! Most of them are about 5 lines of code.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Now you're begging and screaming at us? Maybe you should do something else...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Where you call print() you can break out of the loop.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
a[r[i]] = zero[i0++];
a[r[i]] = one [i1++];

Also, at least consider what NathanOliver said.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Any tips on how to solve this?

Not without a better description. There is no explanation what r contains.
You didn't tell us but a seems to contain your 4 random numbers.
The indexes into zero and one -- are those just guesses? It there any reason those numbers were chosen?

You really need to explain fully before anyone can really attempt to offer advice.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

here is the insert function I will consider your notes but what is the problem with my code??

You tell us what the problem is. Reading code is hard enough without searching for some unknown error.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Ohhhhhhhhh. In other words:

I want to enter a hex value. Then analyze that value and determine how many hex pairs that value contains.

What's the largest value a hex pair can hold?
Simply divide by that number in a loop, the same way you did for 10.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

and this is the error : "63 C:\Users\UseR\Desktop\main.c [Warning] passing arg 4 of `qsort' from incompatible pointer type". "

What does qsort() expect as a 4th parameter? What type of value?
Is comp one of those or is it something else?

It also gives those errors too: "75 C:\Users\UseR\Desktop\main.c syntax error at end of input " " C:\Users\UseR\Desktop\Makefile.win [Build Error] [main.o] Error 1 " "

Reformat your program so its formatting is consisent, not haphazard. That usually solves this type of error.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Write a program and find out rather than waiting 7 hours for an answer.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You are asking two different things expecting to mash them together. Also your initial expectation is wrong....

%x is for numbers, not characters.
unsigned char *s is a pointer to character, but it doesn't actually point to one. It points somewhere but no one knows where.
4200FF would be 3 characters, not a single character.
Is 4200FF the contents of s or *s?

An example of whats contained in s is "4200FF" as its a prompt for the user to insert hex address.

Why does 4200FF define a "prompt for the user?" I think it's just junk because of an uninitialized pointer.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

And my question is also exactly what you need to consider.

Now, answer my question...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You don't put the struct into an array. You make the structure an array:

typedef struct 
{
    int studentnumber;
    char name[30];
    char surname[30];
    int midterm1,midterm2,midterm3;
} Student[30];

As for:

writing all the data in the file

just create a file using any editor (like NotePad) that contains the data you want to read.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

That's what happens when someone over-explains something when in fact a previous post answered the question...

If

The issue is as identified by Lerner

why the long disertation that only confused the poster?

Also:

the stuff with the constructors isn't too difficult.

It is when

I have only had one class in C++ and have done some minor learning outside of it.

When someone is struggling with one thing, heaping more on them is just more confusion. A step at a time.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

How do you take the string of characters '1','2','0' and turn them into the integer 120?

By the way 120 can be of any base from 3 to inf.

Yes it could. Ignore that for the moment.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

In addition, if all you want to do is test if switching is better, all you really need is:

Loop:
    get random number 0-2          ; 1 of possible 3 'doors' chosen
    if number = 0                  ; 0 is defined as the good door
        switchNo = switchNo + 1    ; count no switch condition
      else
        switchYes = switchYes + 1  ; count switch condition
    End Loop 

    Print switchNo switchYes

This assumes door 0 is always the correct door, and one door is randomly chosen.
In the Monty Hall Problem, the moment a door is chosen, the swich condition is immediately known. Showing an unchosen poor choice has no bearing on this switch condition -- it's a red herring to 'confuse' the (L)user.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I don't understand what that means.

1) You create the date file.
2) You write a program to read the data file and put the data into your struct/array

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

How do you convert 120 to int?

What base is A2C3?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What you posted is not a failure. It a lack of attempt.

Read your text book about defining a structure.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

For more information on what is and isn't a whitespace character see the documentation of the isspace function.

Or better yet, write a quick program to loop from 0 to 255 and call all the isXXX() functions and print the results in a chart:

char isspace isdigit isalpha ispunct ....
0x00    F       F       F      F
...
0x20    T       F       F      F
...

Then you can have a list at hand if you ever have doubts.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

It seems to me that the error "no instance of overloaded function" means you have not defined the proper namespace at the beginning of the program. This could cause the 3-parameter getline() to be unknown.

Also, see this about reading and looping (feof() is identical to your (.eofbit`)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

There is no polynomial. It a simple addition or multiplication problem.

Convert A to int.
Store operator.
Convert B to int.
Convert Z to int.
Calculate A operator B.
Compare with Z.

Easy-peasy.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

abc was never set to NULL. It contains junk since all you did was define it.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Must use at least two functions, not including Main

means you must have to functions in addition to main(). Yes, this comes from the experience of reading bad instructions from instructors who aren't clear.

i don't understand why you start yelling after my every post!

I'm not yelling at you. I'm correcting the misinformation you keep posting so the OP gets good information.

All you need to do is to read the question more carefully, and explain your response better.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I never said that using double will solve the problem.

Yes you did.

You said "yes, you'll get same value if you use double." That implies that the problem was solved, which is wrong.

If you didn't mean that, you should have expounded on your information.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

It isn't. Your suggestion is worthless and will only confuse the OP since nothing you mentioned was even asked for. Instructors don't teach tricks in beginning courses.

I_m_rude commented: experince!! :-) +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

For this, you have to use macros. you'll have to define two functions which indirectly point at main(). You will not see main() written anywhere in the program but it actually gives a logical call to main(). Give it a try use ## macro.

What the heck are you talking about???

Macros? Why?
Point to main()? What's that mean?

Why would you not see "main() written anywhere in the program"? That's not how a student learns to program.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You use setter and getter methods:

class testClass 
{
    private:
        int value;

    public:
        int GetValue()
        {
            return value;
        }
        int SetValue(int v)
        {
            value = v;
        }
};

This way the class has total control of the data for safety, but other functions can still access the value.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Get your terms straight.

You don't "create the file" to store it in an array. You open and read an existing file to store it in an array.

So in detail (excruciating detail) explain the first part of the program you need help with, and show us what you've tried.

Is this homework? [edit]Doh -- read the title, fool![/edit]

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

First, create the structure and include all the grades (and all the data) from the file.*
Create the read function to read a student record.
Next create a write function that displays the data for 1 student.
Write the main function to:
1) read all students
2) display all students

Once you have that, you can then move on to the rest of the project.

* By including all the data, you can expand the program to do other things as time goes by. Simply add another function or two and a new menu entry.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

We need a key that nobody would ever use for anything else. Like that opening apostrophe on the key with the tilde. Nobody uses that....

Well, why don't you design a better language for marking text? When it's working, you can probably make a lot of $$ selling it.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Which main one?

Why presume? The poster should explain -- not make us read between the bits.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Obviously no one since you were able to post.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

yes, you'll get same value if you use double.

I really wish people would learn the details before regurgitating bad information all over these forums.

No, double will not correct the problem. Float and double both have the same inexactness problem, just at different levels. It cannot be solved. It simply has to be understood and dealt with.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

@WaltP

It depends on the environment you are coding in.
Chaacoali got these two symbols but you may get different or even the junk you are talking about!

Duh... Isn't that what I said? I thought I was fairly clear about it.

No, it doesn't depend on the environment you're coding in.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Can you not just take some code, then go onto different forums (Java, C++) etc.. and ask what the code is,

You shouldn't. You should post in a more generic forum (Computer Science) so you post only once. Also, since you don't know what language it is, posting Perl code in the C++ or Java forum is frowned upon -- therefore Computer Science.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If you've ever written C/C++, it's no different than writing a string. You just have to remember that * is also escaped...

In C: it's http:\\\\*, in markdown it's http:\\\\\*.

So what's the big deal? ;-)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

When you copied the string into str2, you neglected to terminate the string with '\0'. So those ? characters were just what happened to be in memory after your string. The printf() printed the string until it found a '\0' -- in this case it was close. In other cases you could have displayed pages of junk.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

instead of #define, use typedef keyword..
this keyword is actually meant to define a different name to the existing keyword.
so i think that will be more preferable.

Wrong. What happened when you tried it in order to verify your information before posting?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

why root is not NULL? or how can i make it to NULL?

Why do you want it to be NULL? You just malloced some memory and put the address of it into root. Do you really want to loose that memory causing a memory leek?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

iam not a highly efficient programmer .iam still in learning the beasics.

So learn the basics!!!! Stop trying to understand how to build an airplane when you barely understand how to ride a bike. You clearly don't understand pointers well yet. Why the hell are you trying to deal with double and triple pointers???

And compilers don't stop working! Your CODE stops working!

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Context, it's important.

So is formatting, since your code is unreadable without it...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

MAIN IS NOT A VOID FUNCTION! STOP USING VOID!!! If you want to program correctly, USE THE HELP WE'VE GIVEN YOU!!!