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

Are you supposed to use 6 different variables? If not, an array make the program easier.

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

The closest is a character array:

char *name = "Jody";       // create a pointer pointing to the name of 5 chars
char name2[] = "Mary";     // create an array of 5 chars to hold the name
char name3[20]= "Janine";  // create an array of 20 chars to hold the name

Since they are character array 'strings' they all end in '\0' designating the end of string

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

Can't read the code because of lack of formatting. Try again.

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

@deceptikon

brother's wedding going on, that, coupled with him letting me play with his leica m8 while he's busy being the groom is turning out to a major distraction. :D its the reason for this late reply.

There is no need to apologize for late replys. We are not timing anyone. What makes it late anyway? For all we care, 2 weeks later is not even a late reply.

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

1st: Store the password in a file. Read it in for the compare.
2nd: For more security, encrypt the password somehow. Decrypt it before comparing.

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

First: Learn to format your code consitently. It's difficult to follow.
Second: feof() is used incorrectly.
Third: system("pause") is not a good way to pause a program.
Last: scanf("%s",&text); is dangerous. fgets() is much safer.

Since you didn't explain what you are trying to do beyond reading and writing the file, just use fgets() to read each line and write the line where you want.

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

I looked up the format but it looks nothing like a bitmap...

Why should it look like a bitmap? It's a PNG format.

... and I read the GDI doesn't support PNG's. So how does LibPNG do it then?

By not using GDI I suppose. Since it's called LibPNG, it was probably designed to deal with PNG files specifically.

I don't want to use LibPNG or anything. I want to do it myself.

Then you need to completely understand the PNG format. More study is necessary. Aren't there books that discuss the format? Since it's a free format, there are sites that discuss the format.

I tried changing BI_RGB to BI_PNG but that just corrupts it all.

Does that surprise you?

There isn't a single tutorial out there on reading and using the PNG format with C++.

You need to understand the format itself, irregardless of the language you want to use. The format is everything. You don't want to learn how to read with C++. C++ is just a tool. Once you understand the format, you can use any tool you want, including C++.

Reading images is not a simple task. They are quite complex in design. You'd be better off with a tool designed to deal with the format rather than designing your own.

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

Try these for your formatting needs.

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

I'd also study about useful output messages:
Error deleting file -- which file?
File successfully deleted -- which file?

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

hey can anyone help me with the decrypt part...cant seem to get it to work....

Since you didn't bother to give us any information at all, all "I can say is figure out why it doesn't work and fix it..."

Give us some details on what it does wrong and we might be able to give you a useful answer.

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

My guess is that codepad.org is breaking when it gets to cin >> input--it looks like the site doesn't do interactive input.

If you want to make it work there, replace any cin lines with string literals. You'll also probably run into problems with system("pause").

If the site doesn't do standard C++ commands like cin what makes you think it would do a system specific O/S calls like system("pause")?

The mind boggles... 8o]

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

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!

And put only the code in CODE Tags -- not the entire post.

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

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

the thing I am confused is already been corrected but then I am stuck as I have no clue how to continue coding?

And this is supposed to give us the information we need to help you? Think about actually asking a question we can answer.

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

Look up again how to use a character array as a string. You are missing a couple key pieces of information about a string's length and termination character.

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

Why is Dani Web so agitated when people ask a question? This person didnt understand something they came across and decided to post here to better understand it.

Because based on the first post it is just another request to do his homework for him. He didn't ask for clarification. He asked for an answer.

Since we are not a homework service, and we get scores of these "do my work for me" questions a day, after 50000+ of these requests (in my case at least) we get very irritated at lazy people that can't be bothered to
1) ask and intelligent questions
2) try it first, show us what they did, then ask for help
3) and many other "I can't be bothered, you do it" type of posts.

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

How to figure out logical solutions to problems would be a good start.

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

end_do_while

Since there is no do_while a simple end_do would be clearer. ;-)

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

We are capturing each network packet which is in this format.

What format? A list of bytes is not a format...

The problem is that we would like to get the url if it exist in the packet in the form of http://...... ? What is the best whaay to interpret it to capture the url?

Look through the bytes for the values of 'h' 't' 't' 'p' in consecutive order. What follows is your url.

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

I just use C

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

I guess I should have added "and yours is not a rare case". Get rid of conio.h and getch()

Also, posting code with no information is bad. We like to know why we're looking at your code.

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

Every program I have made, can be run in Windows 95, 98, ME, NT, 2000, XP, Vista and 7. It supports nearly every version of Windows, also the new ones.

Bowls made by the Mayans and by the Sumerians still work today (if found intact). Which are better? And are they better than the bowls actually made today?

While ancient compilers from pre-2009 work, are they the compilers of choice for the current day professional?

;-)

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

Actually, yeah, it probably matters in at least one case. If there were 1000 views with no responses, the OP will probably get upset that no one cares about him. Therefore, the number of views could make someone feel bad. Hence, number of views should be left in the bit bucket.

By the way, while I was typing the above, the cursor was 6 characters before the character being typed. IOW, after typing bucket. the cursor was on the b, not after the period. FYI.

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

It's a pointer that points to a pointer that points to a char

As for how it works, work it out. Draw a map of memory and see how it could possibly be layed out and used.

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

Whould you care to give us some idea what is wrong?

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

Problem #1:
Never ever put code or variable definitions in a header file. Header files are used to declare functions and variables, not define them.

Problem #2:

void showList(const int list[], const int n)
{
    cout<<"The list is ..... " <<endl;
    for (int i=0; i<n; i++)
    {
        cout<<setw(8)<<right<<list[i];
        if ((i+1)%1000==0)        // What are these 2 
        cout<<endl;               // lines supposed to do?
    }
    cout<<endl;
}

Problem #3:
In all your functions, why are there so many blank lines? It makes the code very hard to follow.

I've looked through the program through the call to printList() and don't see any problems with crashing. You might need to be more specific.

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

This is more of a rhetorical question, but...

... how is the article Flame on: complex LUA and C++ cyber weapon fired at Israel, Iran and Syria related to C: Access violation 0xC0000005:???

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

1) It's crAsh, not crUsh.
2) See this. Your use is undefined.
3) Be consistant in your formatting. See this

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

AFAICT, we've unfortunately lost the ability to close threads... It's at least marked solved, so maybe more braindead responses won't be added... We'll see.

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

Apologies.

If I knew what was wrong, there wouldn't be a problem.

Obviously you don't know what the problem in the code is, but something happens to make you say it doesn't work. That's what you need to describe clearly

If your asking what happens when i compile, then the program just crashes.

It obviously doesn't crash when you compile. If it did, the compiler crashed -- I doubt that. Therefore I assume you mean it crashes when you run the compiled program. Describe how it crashes -- error messages, any output, etc.

while(sscanf(line,"%d", &data[y++][x])); /* i found this line online so i dont really understand why there is a while and why its not working */

This is your problem.
1) If you don't know why there is a WHILE there, why did you put it there?
2) If you don't know why it's there and it's not working, maybe that's the problem.
3) Why would you just use a random line you found online and expect it to do what you want?

What is that line supposed to be doing? How many times?

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

If you don't understand what you are writing, you should not be writing code. You need to sit at a desk with pencil and paper and plan -- yes plan -- what you need to accomplish.

Write down what the task is.
Break that description into pieces -- like in English class, what are the nouns, verbs, and the implied parts (but don't really look for nouns and verbs -- that's English class)

Write down how you accomplish each task. Then break that down into smaller pieces until you get to the point each step is as small as it can get.

There's your design. Now run through it by hand to see if it does what you want. Write down variables as they change. YOU be the computer and that description is your psuedocode.

When that's done, works, etc., now you're ready to start coding. Take a section at a time. Do the input. Get it working completely. Add the output. Get it working. Then one more step. Get it working. Add another... ad nauseum.

That's programming! (sorry, but that's really how we do it.)

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

My program thus far is not working out...

Why is it no one likes to explain what the code does wrong and expects us to figure it out for ourselves?

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

Write the pseudocode to find the record with a specific studentID

Well, do what the instructions say. If you have a list of numbers, how would you find a specific number?

Assume each number is on 1 index card in a file box. Write down each step (the psuedocode) you use to find the proper card. When your steps work, you have psuedocode that should be easily translatable into C++ Code.

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

Who is Sqr? And why are all your posts in Code Tags?

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

erm, whats wrong with my code? anyone can tell?

erm, not if you don't tell us where the errors are...

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

When you are asking other people that know how to program to read your code the difference is large enough.

Professionals have learned proper formatting techniques and when someone messes with that, it does make it harder to follow the code.

Why do you feel your way is better?

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

To make your code more readable, look at how pyTony wrote the subscripte value. I'm all for using SPACEs, but too many also make code hard to read.

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

A much simpler way, if this concatenation is just part of a much bigger program, is to use atoi and itoa. itoa() the two numbers, then strcat(), then atoi() back.

atoi() is simpler than (x1*10) + x2? How do you figure that? Please explain...

And itoa() is not generally available (see portability).
Or did you mean Illinois Tactical Officers Association? :-P

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

What reason? So anyone who doesn't have your exact compiler and O/S can scream in frustration because they can't try your program? Other people don't think getting punk'd is fun. ;o)

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

Not a clue what you don't understand. A MIN and MAX are quite obvious so without knowing what bugs you, we can't very well answer your non-question.

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

255 is -1 in 8 bits.
65535 is -1 in 16 bits.
Your 255 in the G section is getting promoted to an integer

Instead, try shifting then ANDing to get the correct bits, using the 32 bit cast:

inline RGB Rgb(int R, int G, int B) 
        {RGB Result =   (((uint32_t)R << 16) & 0x00FF0000) | 
                        (((uint32_t)G <<  8) & 0x0000FF00) | 
                        (((uint32_t)B) & 0x000000FF);