The correct form is:
(rand() % (max-min+1) + min;
The correct form is:
(rand() % (max-min+1) + min;
Finally!! Congratulations!
JPGs are not stored by pixel, so adding 1 to any value would change a lot of pixels, not lighten 1. You need to look at the JPG format more closely.
Look at each character and convert to decimal. Easy peasy. strtoul()
will take time and testing to understand, you can convert this by hand in 10 minutes.
It's a game he's hacking. He has 2 active threads on the exact same question and we're bouncing back and forth telling him the same stuff twice.
Look up the function toupper()
and tolower()
.
Maybe algorithm = formula in this case.
Jason, Since this is the C forum, why all the C++ suggestions? Steer him correctly to C solutions.
You need to look up what perror()
actually does. It's not in the wrong place, you're just not using it for the purpose it was intended.
Also, don't use conio.h
and getch()
. They are non-standard and will cause you headaches when you get to the other 98% of the compilers that don't use them. There are standard ways to accept input that all C++ compilers have available.
And use a loop instead of goto
s. It's bad programming practice to use them when there are better control structures available.
Loook up memcpy()
You have been told how, you have been given the resourses, you have even been given an answer you can use as a pattern. Your turn.
If you still want it done for you, I charge $100 an hour, minimum 3 hours for consulting work. Student rate $93.50 if you can prove you're a student. PM me if that's acceptable and we'll work out the details.
OK, here. It took me all of 45 seconds to do this. With your lack of skills, it would have probably taken you 15 minutes to do the same thing instead of whining and complaining for the past 17 freaking hours.
4B 50 7B F1 F4 F5 5E 50 7B F1 F4 F5 5E 4B 4B 4B
K P { ñ ô õ ^ P { ñ ô õ ^ K K K
There's your translation. Enjoy. Now Mark this question solved.
yeah buy not all of the codes i have are there alot of them aren't on the chart
Bull. Every code is on that chart.
I guess it tells us something important.
anyways that chart some of the codes i have arent on there.
Doesn't that tell you something important?
You can easily do it yourself. Just look up those hex numbers in any ascii chart
i dont know how :(
Follow his link and figure it out. It's simple.
No, the compiler doesn't know. You told the compiler that the variable was defined somewhere else. That's all the compiler knows. It trusts you.
Its when you try to link the declaration with a definition that the linker finds your error.
If you read my post you could get rid of all that error fixing and handle the input of "53 is the number" which you claim is an error but all these cin.clear
s and cin.ignore()
s don't handle at all.
Line 14 is a strtok()
. Since when does strtok()
print?
And I repeat:
How do you know it's not "model\n" or "model "?
Any ideas? Am I misunderstanding cin?
Yes.
Using cin.getline()
reads the entire line so you don't have to worry about characters left in the input buffer.
Speaking of re-using cin, I've run into a couple of issues with that. Namely:
- I've been using cin.get() before the main function returns, to enable the program to pause so I can see the output. This works fine, until...
Remember, cin.get()
reads a single character. When you get to a prompt that says "Enter a character:" and you type in 'A', how many keys do you actually hit? Therefore, how many characters?
- I use cin to get user input earlier in the program. If this is the case, the cin.get() at the end of the program won't do anything
Yes, it does something. It read a character from the input stream. See above.
I read that cin.clear() would let me re-use cin, but this isn't the case; if I have cin.clear() and then cin.get(), the program still doesn't wait for input at the cin.get().
That's because cin.clear()
doesn't do what you read... Look it up at a reputable site...
At point 1 string str is "model"
How do you know it's not "model\n" or "model "? Neither of those will match "model". For that matter, how do you really know what is in str?
you can declare them on the same line... it looks cleaner
I disagree, but that's just programmer's preference...
Use loops and if statements.
[boilerplate_help_info]
Posting requests for help must be well thought out if you want help quickly and correctly. Your post did not meet the criteria for quality help. You may get some posts, but are they going to be useful? Check your post with these checkpoints - what is it you missed:
Sorry, missed the first method and zeroed in just on the pragma...
Depends on what you need to do. If you want to use "pre-defined data types like java", use java. If you want to use C, you need to use the data types C has. Or find a third-party library, such as the one already mentioned.
Enter it into a temporary input buffer. Then move it into place in your array.
np complete: you can handle such number by linked list.
Major overkill. Since the numbers must be kept sequential, why do you need a structure containing and int and a pointer and all that code to insert/delete/traverse nodes?
A simple array is the answer...
I don't use VC at this time but doesn't VC offer a way to disable errors from the project/IDE settings? If not, that figures...
@np complete
What your idea does is make sure there is a decimal portion to the number. But 5.0 is a valid floating point number.
What the OP need to do is basically what NathanOliver describes.
I'm new to C++ (bet you guys don't hear that very often!!)
Nope. Never. :P
What I want to know is why everyone thinks they have to tell us that. It's bleeding obvious based on the question and the code!
Just realised that I'd still entitled this "bit of weirdness".
which is technically in violation of the Member Rules: "Do use clear and relevant titles for new articles". Use a title that give us an idea why you are posting. In this case "Testing Input Validity" or something like that would be a proper title.
That was with regards to "goto" that I was trying earlier; I looked it up and everyone seems to agree that goto is obsolete.
It's not that it's obsolete (it isn't). It's just bad practice.
I think you should try this approach too.
Where do you imagine he used it? Look at his code again... :rolleyes:
Yes, turn off the error message for the compiler. M$ has decided to rewrite the function, but since the function they wrote is not standard, they also decided to annoy us with their "we're better than the standard" attitude.
It's not his code. It's someone else's code ;)
So? Does that make what I said wrong? :P
Follow Kwetal's advice. What are you trying to learn from this code?
It means strcpy()
does not take 5 arguments as you tried to do with strcpy(winKey[1].key, '1','2','3','\0')
Look up
1) How strcpy()
works.
2) Concentrate on it's parameters and how they are defined.
3) Look up how strings are laid out (their definition).
1) You don't -- this is the C forum.
2) Set insert mode off, set the cursor on the s, and type.
these small programs doesn't really need inheritence,
It does if
The main purpose of this example is to execute inheritance
It's how we learn.
It's what happens when you set up an array like int array[10]
and use a statement like array[12] = 23;
. There is no array[12]
. It only goes to array[9]
.
In your case, "123"
is 4 bytes, not 3. it's '1','2','3','\0'. You forgot about the string indicator.
You are generating the random number correctly, just not using it correctly.
1) You don't need all that preamble to set up seconds and call srand()
. It's easier (and less confusing) if you simply replace lines 10-12 with srand(time(NULL))
. Generating seconds is obviously confusing you.
2) You output a random number but didn't store it so you have nothing to compare your input with.
cout<<'a'+0;
?? You're kidding, right?
Standard way to do this is cout << (int)'a';
Don't understand. You mean the idiots that charge for bandwidth and disk space? Isn't it their servers and their internet connection? That was my main point. Spam was just an incidental. Reread points 1,2,3. No spam.
What would you do with the character if you read an 'A'? Do that with the '/' in the else
then continue as normal since c now contains the next character.
read char
if '/'
read char
if '/' ignore rest of line
if not '/' do your stuff with '/'
do your stuff with char
Not a good idea IMO.
1) Many (most) of us won't open attached files or linked images. We certainly won't watch a video.
2) As you pointed out, "It may require huge database and huge maintainence of daniweb server." Who's going to pay these extra costs?
3) You gave the solution already: "[upload] a video on youtube or someother websites and [paste] the link here".
And in concert with 1 & 2 above what about spammers that upload porn? Why should DaniWeb pay for all the bandwidth that was completely wasted?
Read it.
GUI means Graphical User Interface. It has nothing to do with triggering anything. It's all the pretty stuff in windows, like title bars, sizable windows, arrow cursor, menus, icons -- all the stuff people think a computer must have.
IMO, if you're such a rookie, you don't need to understand anything you currently asked. That comes later when you understand the language itself well. Then you can delve into this advanced stuff.
In slightly more detail:
get the character parameter
output the character to the screen
get the format string
parse and analyze the string (not trivial)
find out that there's a CHAR format specifier
call the char output subfunction (as opposed to integer, float, octal, etc...)
get the character parameter
output the character to the screen
By the way, scanf()
does the same stuff. Use getchar()
for character input.
Oops. Missed that...
Too complicated. You can do this much cleaner and without the valid_input variable.
And just for future user info, if anyone puts a \007 in any output statements I have to use, someone's going to get strangled. It's an annoying practice from the user's standpoint.
You should avoid goto
completely. After 30 years in C, I've never needed one.
Restructure your program to use one of the 3 loop structures.
As for why it executes twice, when you type your answer, how many keys do you actually press? What do you think is now happening?
[edit]
One more thing:
Why use an expensive function like scanf()
to read a single character? getchar()
is specifically designed to read a character without all the overhead.
It won't solve your double-execute problem, though...
[/edit]
Does it work?
If so, probably. Test it with a lot more data.
If not, no.
Please don't use getch()
at the end of programs. It's non-standard and when you get to a real compiler, you'll have problems.
What to replace it with? Well, what does getch()
do? What standard statements do the same thing? Use that instead.
4th option:
Make a zeroed array of 5,00,000 integers.
For every integer read, use it as an index into the array and increment that entry. When done, the value that's 1 was read once.
But shanki himanshu's solution seems to be the most efficient. It's a really slick solution.