>Write a program that will allow randomized 0..100 numbers
> random_integer = (rand()%100)+1;
That gives you numbers from 1..100.
Type: Posts; User: swoopy
>Write a program that will allow randomized 0..100 numbers
> random_integer = (rand()%100)+1;
That gives you numbers from 1..100.
>Is it possible? if yes, how do I do it?
Try this.
#include <cstdlib>
#include <iostream>
#include <string>
int main()
{
std::string tag;
> char c;
Declaring c as an int will likely fix your problem. Also a better way to control the loop is:
while((c=fgetc(fp)) != EOF)
{
It depends on what function you use to write each data item or struct. If you use fprintf(), then text mode should be fine. If you use fwrite(), then you need to use binary mode.
This is C, not C++.
Yeah, having two names is probably just for convenience. It makes it easier to read code. It seems like they could have just had one function, but maybe coming up with a good name would be a...
I'd be very surprised if that's the case.
>I did not use the ntohl or htonl because I have to choose which one. This works both ways with the same routine
As long as you don't sometime in the future run your code on a different platform,...
>and it prints the correct value
Just be sure you assign the result to something back in process_cmd().
And you never assigned the return value to anything:
var = BYTESWAP2(ccmd);
Or you could simply print out the value of BYTESWAP2(ccmd).
You have two of your masks incorrect, this one ((ccmd&0x000000FF)<<24) and ((ccmd&0xFF000000)>>24). And for maximum portability, the input to BYTESWAP should be an unsigned int:
int...
>The problem is, what happens when you want to do arithmetic on the stuff that is being put in?
_getch() only inputs a single number per call, so if the user entered 123, you'd have to combine them...
>Why does this tell me i'm missing ")"'s?
>sizeof wxString
I think you need sizeof(wxString), only because wxString is a class, or you could also write sizeof billdat.Cost.
>p.s. Will it work?...
Use tabstop's idea, and <ENTER> will probably compare equal with either '\n' or '\r'.
>void main()
And it's a good habit to return an int from main, since void main() is wrong.
int main(void)
{
.
.
return 0;
}
>Can you please explain me why it wasn't k earlier...coz the pointer also would give the same size of the node.
node is defined as a pointer to struct nodetype:
typedef struct nodetype *node;
...
You might need to use the actual object:
node tmp = malloc(sizeof(*tmp));
>node tmp=(node)malloc(sizeof(node));
Make this:
node tmp = malloc(sizeof(*node));
You should also #include <stdlib.h> for malloc().
I'm not spotting any problem with your code. Try traversing the tree after every insert(), and let us know what it prints for the tree:
insert(&mytree, num);
intrav(mytree);
printf("\nEnter...
How much memory did you allocate for screenDataPnt (or whatever buffer that points to)?
>open it as fopen("rb") instead of ("r")
Correct.
>read the file in text (not binary) mode.
Wouldn't it be the opposite?
Also I'm assuming you set *array to point to resizedarray at some point. And MacGyver makes a good point about & in front of tmp for the scanf().
>Also, shouldn't I free the original array regardless and set it equal to resizedarray?
No, because resizedarray may actually point to the exact same memory.
I may be wrong about this, but I...
>do this mean I need to declare a new char ** and set the realloc equal to it
That's the preferred method, because in case realloc() returns NULL, you can still free the original before returning...