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

Most likely mis-matched braces. If you would indent in a consisent manner , that type of error would never show up.

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

If people would stop responding to these posts, we could actually do something about them.

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

Which is the best compiler for C++ development for latest versions of OS like the 64 bit windows?

Best? What makes you think there's a best? If there was a best, there'd only be one choice.

The DEV C++ compiler is a good option but I find it problematic for file handling.

What's that mean?

Visual C++ is also a good alternative but I couldnt find any command for compiling and running the code.

It's there. It's called RUN. Probably under the DEBUG menu.

G++ compiler is good but it does not support the windows header files.

Windows header files are not standard and only work on Windows O/S. There are many other O/S's out there so you are limiting yourself if all you want to use are windows headers.

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

Maybe

x = rand() %2;
if (x == 0) x = 1;
    else    x = 3;
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

In the loop what is the value of i?

Ancient Dragon commented: Oops missed that one :) +14
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

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

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

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

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

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

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

whats wrong in my codes

1) main() is an INT function
2) defineing printf and scanf makes the code difficult to follow and is unnecessarily confusing
3) As pyTony mentions, you need to format your code properly.
4) Use a standard function (getchar()) instead of the nonstandard getch().

That's what I see.

Also, when asking for help, details are important. "Wrong Answer" tells us nothing. What did you get and what did you expect based on what input was used?

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

Point number 4: I was under impression that once a new memory is allocated to my code, that pointer would be pointing to some random data present at that location at that time.I did not knew that realloc already does the 'createACopy' task for me.

New memory, yes, reallocated memory, no. It really does help to understand the functions you are using. Read before using so you know what you're doing.

One more thing. I am new here. I would be trying to answer questions by others. But please cover me if I am giving incorrect informatiom.

Be sure you test before answering. This includes testing code and verifying your information before responding.

It would really help if the person asking the question does a little checking first, but that rarely happens.

teachMyself commented: Sure Thing. +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

In addition to what The Dragon said:

1) Never use conio.h and getch() if at all possible. They are non-standard and are only defined in a couple compilers. Use a standard input function. In your case I understand why you used it, but in general, avoid getch()

2) Line up your comments as much as possible:

if (userInput == NULL)                //if malloc could not find sufficient memory
{
    free (userInput);                 //free the memory
    puts ("Error Allocating memory"); //print error message
    exit (1);                         //exit the program
}

3) Make your comments useful:

free (storeOldInputHere); //free the storeOldInputHere
inputLength ++; //increment the length counter by 1

Both comments are worthless. Good comments explain why the statement was used, not what the statement does.

4) realloc() does not loose the contents of the memory so the createACopy function is not necessary. See this

5) using exit(1) from the mainline is not necessary. return(1) will suffice. exit() is used when you are deep inside functions and must exit when returning with and error code is not an option.

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

So pick a better compiler

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
i++,++j;
k = i>j? i: j;

That's not your macro. The macro is only 1 line.
Try it again.

Study the definition of a magro again.

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

Try it and find out! You'll get the answer in seconds!

I fear for the future

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

Passe. When you can get an anwser in hours by posting a question and spending no effort, why spend the energy to open the manual and get the answer in seconds?

I_m_rude commented: a BIG LOL +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

((-b) + sqrt(bb-4ac)) / (2a)

See that /? Don't do that. Assign numerator and denominator to separate variables and print them out.

num = ((-b) + sqrt(b*b-4*a*c))
den = (2*a)
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Lucky you... It must be your signature 'cuz IT Consultant usually makes grls run away! ;-)

Just report the spammer (as you did) and they will be banned.

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

if(user=="abel" && pass=="pass")

Look up how to compare strings again. You need to use strcmp()

And remove your 2 #define's. They make the code harder to understand, not easier.

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

Companies always ask these tricky-defination type questions.

They do? How many job interviews have you been on?

Paraphrasing for ease of understanding:
An expression is that portion of a statement that has operators (*+-<> etc).
A statement ends in ;

There's more to it but that's what you can grasp at this moment.

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

They are incorrect. Anything that is "compiler dependent" should be avoided.

As deceptikon said, it's undefined. Listen to experts, not friends.

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

How to start...

Same way you do with any program
1) decide what you want to make (without graphics)
2) write down how the game works
3) write down the steps it takes to play the game
4) expand each step until you can't expand it any more
5) write code to do one thing and TEST FULLY. Do not continue until this part works.
6) add one more thing to it (see #5)
7) continue until the game is complete.

and how to end?

Stop coding.

what kind of game can i try to make?

Something without graphics

which IDE to use ?

Whatever you want

i cant run <graphics.> header file for graphics in any IDE. How to configure init() = (&gm, &gd, "C:\Tc\") in Turbo C. How to use simple code and not very complex code.

Don't. You don't need graphics.

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

What numeric system do you know where 1 + 3 = 5?

It's obvious -- for large values of 1 & 3 and small values of 5! ;o)

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

Concentrate carefully on this loop:

while(atSymbol(emails[i]) == true)
{
    i = 0;
    i++;
    if(emails[i] == '@') break;
}

1) In the while, aren't you looking specifically for an @?
2) Is the break really necessary with the proper while statement?
3) Comment each line to explain the reason for the line.
4) Use pencil and paper and execute the loop to see if it does the correct thing.

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

ok waltp as u say i wont use gets() but using gets() its easy to read a string right...

Using a bulldozer to open your front door is easy, too. It that the safest tool?

... so what else can i use scanf????

here -- here -- here
Actually read the help that you have been given.

and perry 31 i tried ur code its producing wrong output but does not show any error

And this is one reason why we don't give away free code, as well as the reason it's called cheating... YOU don't get the grade, and THEY don't deserve the grade on your work.

I_m_rude commented: damn funny comment! +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

And what part of "*don't use gets() *" is so difficult to understand?

If you want further help, start using the help you've been given. Otherwise, why should we bother?

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

No it's not legally binding. Yes it's possible.

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

@Rashakil Fol what the hell aare you talking about!! :O ??

Nothing. He's being an a$$.

happygeek commented: indeed +11
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Yes, ASM can be very useful. If you need to rewrite a function because its too slow, ASM can make it quite a bit faster. If you need to interface with a module of some kind and C++ is too clumsy to do the interface, ASM to the rescue. Drivers can easily be written in ASM.

How do I know which register to put stuff in?

If you are calling a function, interrupt, or something already written, that info is in the documentation of the function. Otherwise, general registers are used as variables so it doesn't matter. Some registers have specific definitions, so only specific type of data will do into them. You learn what's what as you learn ASM.

triumphost commented: I see I see. +1 +5
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Secondly, never, ever use gets, always use fgets, so not gets(sh); but fgets(sh, sizeof sh, stdin); it is safer since you can't overwrite the buffer,...

And the exact same thing goes for using scanf() to read strings. It's as bad as gets().

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

#define FOR(i,a,b) for(int i=a;i<b;i++)

Why? What's wrong with just using the for statement? Making it a define simply makes the program confusing.

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

When asking for help, EXPLAIN what problem you are having. Do not expect us to try to figure out what it does wrong -- tell us!

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

Also don't use #include <conio.h> and getch() because they are really really bad.

Read bad as non-standard and prone to cause problems for you when you start using one of the 99% of the compilers that don't know what <conio.h> and getch() are.

The standard definition of bad doesn't apply. In rare cases, they are "really really good". But it's rare.

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

Code Snippets should not use anything in conio.h. They should be written so anyone can comple the program.

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

Vernon Dozier said

Indent your code. It's impossible to read.

You've ignored him. If you are going to ignore the help you have already been given why should we help you further?

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

So what was the problem? And your solution?

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

Even before the pervious question is answered question 2 is nonsensical. C++ could be written in ForTran or Cobol if the creators desired.

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

Problem is your are using system(pause) to pause your run. You are waiting at the OS at that point, not your program.

C++ has input functions, like cin, getline(), etc that waits better than system(pause). Use them instead. There is no reason to call the OS to pause any program. Same with cls...

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

Do you have a question? A problem?

If so, you might want to explain...

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

Use if statements.

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

Print your code.
Sit at a desk with a pencil and the code.
Write down the names of each variable in a column.
Go through the code line by line changing the variable values as you go.
Follow the loop until it exits.

This is the easiest way to figure out what's wrong with your code. You also learn more about programming.

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

Why do people always need to seek to get the length of a file? In this case, you want to read the header, right? How big is the header? Just create an unsigned char or byte array to read in a chunk of the file -- 512, 1024, 2048 bytes...

The line char newchar = buffer[4]+buffer[5]+buffer[6]+buffer[7]; simply adds the bytes together. What are you trying to do here?

it is displayed as a question mark in the command prompt.

Of what use is displaying a binary file at the command prompt. As rubberman suggests start by displaying the data as a series of HEX bytes. But use be sure to use them as unsigned values because bytes are neither positive nor negative.

trishtren commented: your suggestion is helpful, and the adding the bits together was to try and collect only the bits after FWS, as that already worked i only wanted the version number located from bit 4-8 to be converted to unsigned int, but im still a rookie at following t +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I am getting a crazy number of errors that i honestly do not know what is wrong. I am getting a syntax errot before the "int"s in the switch, and conflicting types of all the function names. Any help will be appreciated.

Then reread the section in your book on how to call a function.

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

Does this mean I have to create a new project everytime I want to run a single program?

Yes.

If you made chili in a pot yesterday, would you want to make tomato soup today in the same pot with the leftover chili?
You either
1) clean out your pot
2) or get a new one.

Humayoon Khan commented: haha nice =) +0
amrith92 commented: haha, nice one! ;) +6
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

This is homework

Really? What makes you think so?

You waited 1-1/2 years to make your first post with this newsworthy information???