Salem 5,265 Posting Sage

http://www.daniweb.com/forums/thread124172.html
Same set of standard replies, then you post some actual effort.

Salem 5,265 Posting Sage

Tell me, can you even write a program to copy a file one character at a time?

Or write a program which can say count the number of 'a' characters in a file?

Or even produce a histogram showing the distribution of letters in a file?
See, having done this, you're half-way there to fulfilling one of your program requirements.

Because the same old plz help, gimme the codez refrain isn't doing you any favours at all.

a) we're not going to give you the complete answer
b) we're not going to give you much help until YOU post some code. When you post code, we know where to start with the explanations.

mrboolf commented: well said! +1
Salem 5,265 Posting Sage

Get nice and comfortable, this is a long read
http://www.faqs.org/faqs/compression-faq/

StuXYZ commented: Just spent a good 30 minutes reading the compression FAQ. Very interesting. Thx. (even if the original poster did bother to look) +1
Salem 5,265 Posting Sage
Salem 5,265 Posting Sage

> I've tried the simple power of 10 tricks and that still didn't help me solve the underlying problem.
Well how accurate do you want the tonnes to pounds to be?

At 3 decimal places, each 1/1000th of a tonne is about 2 pounds.

So for example, 0.318 would be 701.0628, which on the face of it seems closer. Would that be rounded to even 700 as well?

I showed you 'truncate' in the hope that you might figure out 'round' for yourself.

But first, you need to decide what to round to, based on an input of decimal tonnes. If it isn't the nearest 10lb, then perhaps maybe 20 or 50.

If someone orders a tonne of sand, they're not going to be measuring it with a spoon when it's delivered.

Salem 5,265 Posting Sage

What do you get if you
- divide by 10
- take the integer part
- multiply by 10

Salem 5,265 Posting Sage

> void main()
Has nobody mentioned that main returns in in your previous 60 messages?
Or did you just ignore them.

Where do you
- set frequency to zero?
- determine that the word is already in the tree, and thus increment the frequency

> else(start->item==freakword);
I'd be surprised if this even compiles.
You say you've run it, is this your actual code?

Salem 5,265 Posting Sage

> while (x || y != 00) ;
1. Remove the ; at the end
2. This isn't basic. If you want to compare both with 0, then do
while (x != 0 || y != 0)

> z = (x,y);
Meaning what?
z = y;
is what you've written.
z is int, y is double, so that's where the first problem is.

> int (int x, int y) ;
Go back to your book and study how functions are declared.

Salem 5,265 Posting Sage

Consider that your command line parameters are actually stored in memory in a single block of memory.

./StockOrders\0datafile\0logfile\0server\0client
 ^              ^         ^        ^       ^
[0]            [1]       [2]      [3]     [4]

Then you come along with strcat(argv[3], "_fifo") And now it looks like this

./StockOrders\0datafile\0logfile\0server_fifo
 ^              ^         ^        ^      ^
[0]            [1]       [2]      [3]    [4]

Yep, you transformed client into fifo.

The short answer is, if you want to extend an argv, then you need to copy it to somewhere which has the space to append.

Other points.
1) WAY too many functions which return results are being ignored.
2) You're using gets(), the world's most dangerous function.


> if(strstr(s, "quote") && strstr(s, "buy"))
If you have s = "hello world"; and p = strstr(s, "world" ); then n = p - s; would be 5, as in printf( "%s", &s[n] ); would print world.

devnar commented: Where had you been dude? Anyway good to see you again. :P +1
Salem 5,265 Posting Sage

Bored now....

_____________________
                   /|  /|     |                     |
                   ||__||     |    Please do not    |
                  /   O O\__  |      feed the       |
                 /          \ |       Trolls        |
                /      \     \|_____________________|
               /   _    \     \      ||
              /    |\____\     \     ||
             /     | | | |\____/     ||
            /       \|_|_|/   |     _||
           /  /  \            |____| ||
          /   |   |           |      --|
          |   |   |           |____  --|
   * _    |  |_|_|_|          |     \-/
*-- _--\ _ \                  |      ||
  /  _     \\        |        /      `'
*  /   \_ /- |       |       |
  *      ___ c_c_c_C/ \C_c_c_c____________

Go whine at someone else.

If you want to make a real impression, post more than 2 lines of upper case YELLING.
A reasoned argument written in proper English would help you make you sound sane (and serious). Not some spoilt brat who's thrown the toys out of the pram - Waa Waa - Wiki deleted my post WAAAA!!!!

If it bugs you that much, put it on your OWN SITE.

> I take this as a threat and will be calling the FBI
Who are they - the Female Body Inspectors

William Hemsworth commented: Bhah :) this made me laugh.. +4
Salem 5,265 Posting Sage

Perhaps it only bans idiots like you who haven't learnt how to speak properly yet.
http://www.catb.org/~esr/faqs/smart-questions.html#writewell

Plus associated morons who's IQ is lower than their shoe size who go around vandalising content.

Salem 5,265 Posting Sage
Salem 5,265 Posting Sage

Something like
"ntp client c source code"
in your search engine perhaps?

Salem 5,265 Posting Sage

Missing ; at end of typedef.

Salem 5,265 Posting Sage

Er, yes.

Salem 5,265 Posting Sage
Salem 5,265 Posting Sage

> #define MAX_MSG = 100
A segmentation fault means you ran it, and it crashed.
Whereas the code you posted won't even compile (not with that #define).

Also, use fgets() to read a whole line for you (and fopen to open the file).

Salem 5,265 Posting Sage

Or your other post on the same subject
http://www.daniweb.com/forums/thread153215.html

Salem 5,265 Posting Sage

You can't declare arrays using sizes available at run-time.

Given that your function definition has a constant, how about

int board[100][100];
          if(OpenBoard(boardName, width, height, board))
          {
                
          }

//...
//function definition...

bool OpenBoard(std::string *boardFileName, int *width, int *height, int board[][100])

But since this is C++, how about std::vector< std::vector<int> > board;

Salem 5,265 Posting Sage

> BIOS Date: August 18th 2004
Which means the board is probably older still right?

http://support.intel.com/support/motherboards/desktop/d845gvsr/

These products are no longer being manufactured by Intel. Additionally, Intel no longer provides interactive support for these products via telephone or e-mail, nor will Intel provide any future software updates to support new operating systems or improve compatibility with third party devices and software products.

THESE DOCUMENTS ARE PROVIDED FOR HISTORICAL REFERENCE PURPOSES ONLY AND ARE SUBJECT TO THE TERMS SET FORTH IN THE "LEGAL INFORMATION" LINK BELOW.For information on currently available Intel products, please see www.intel.com and/or developer.intel.com

In other words, it's so old that Intel have lost complete interest in it.

You're only going to get so far by putting racing slicks on a model T ford. Looks great, but all it does is really expose how weak the rest of the system is.

By the time you've incrementally (and sub-optimally) replaced several components in your machine, you could have bought a brand new one with all the latest (and matched to each other) components for basically the same money.

Yes your fancy RAM may make it quicker (eventually), but will you ever be able to run the RAM at it's true potential on that old machine?. If the answer is no, then you've paid for performance you're never going to use.

Salem 5,265 Posting Sage

Run mdadm in the forground, hence sequentially.
Run your progress in the background, then kill it when you're done.

And thanks for the explanations :icon_rolleyes:

Salem 5,265 Posting Sage

If you ignore the "progress indicator" for the moment, does this actually work ?

# mdadm --manage /dev/md0 --add /dev/sdb1
# mdadm --manage /dev/md1 --add /dev/sdb2
# mdadm --manage /dev/md2 --add /dev/sdb3
# mdadm --manage /dev/md3 --add /dev/sdb4

Does /proc/mdstat exist before the first command starts, and after the last command exits?

Salem 5,265 Posting Sage

So it does reach the far corner then.

> fill(half, a, q1, 0, 0, xc, yc, pxc, pyc, ++num);
My guess is each of these should be num+1, not num++ (or even ++num)

But then again, I can't see why it would need to be a reference either.

Salem 5,265 Posting Sage

Don't forget, main returns int

Salem 5,265 Posting Sage

> Anything bigger and it doesn't fill it in completely.
As in it crashes with some error message, or some other reason?

Why do you have a 'static' in fill()?
There's only ONE variable, not a separate copy for each recursive invocation.

Salem 5,265 Posting Sage

> numbers = numbers[i+1];
When you're removing, this loop should start at the number you enter, not 0

Salem 5,265 Posting Sage

Well as a guess, a name like "_mysql_get_client_info@0" suggests it is being decorated as a C++ symbol, whereas the equivalent in the library is very much a C symbol.

It seems to me you're compiling C++ and linking with a C library.

> Dump of file libmysql.lib
Is there a libmysql++.lib there as well?

Salem 5,265 Posting Sage

If you post code, then someone will probably be able to help you.

Salem 5,265 Posting Sage

It might, if you use strlen rather than sizeof

Oh, and there can only ever be one newline.
If there is a newline at all, it will always be at
input[strlen(input)-1]

Though you should check fgets() returned success before doing this.

Salem 5,265 Posting Sage

> I've already got rid of the tabs with the tr command so its a lot more cleaner now,
And destroyed any sense of where all the columns are with it no doubt.

If the result is variable width fields, with variable content, which now overlap, then you're stuck.

Fred Flintstone 37 Wilma Pebbles
Barney Rubble 39 Betty Bam Bam

If you'd expanded the tabs with 'expand', and not gotten rid of them with 'tr', then maybe you would have multiple spaces between columns, and some sense of still having a table.

Fred Flintstone     37  Wilma   Pebbles
Barney Rubble       39  Betty   Bam Bam

At least then various utilities can count characters to establish where the fields are.

If you've still got tabs, then extracting individual fields is dead easy.
Eg. awk -F'\t' '{ print $1,$4 }' and save the removal of them until it's absolutely necessary for display purposes say. Even then, you don't mess about with your original data to do it.

Salem 5,265 Posting Sage

Are you meant to use %c?
Because %s will do the whole thing in one call.

Salem 5,265 Posting Sage

Or just do a difftime() between now and next Saturday @00:14, then call Sleep() for that many seconds.

One calculation, one call to Sleep().
5 lines of code, and it's sorted.

Ancient Dragon commented: great idea -- lot simplier than my suggestion +36
Salem 5,265 Posting Sage

What's your definition of "simple"?

Or put it another way, what have you been studying for the past few weeks or months, and how much attention were you paying?

Salem 5,265 Posting Sage
Salem 5,265 Posting Sage
Salem 5,265 Posting Sage

Step 1 - a loop which reads numbers and prints them out (this should be basically the same as a previous assignment)
Step 2 - make it exit on ctrl-z
Step 3 - make it reject out of range numbers
Got the idea yet?

Think about what steps you can
a) acomplish
b) might need to do first

When you've got somewhere (and got stuck), then post back.

Don't just stare at your "elephant" and complain that it's too big to eat all at once.

Salem 5,265 Posting Sage

So if you have

while ( cin.getline(input1, 31, '\n') ) {
  cout << "--" << input1 << "--" << endl;
}
if ( cin.fail() ) {
  cout << "Failed" << endl;
}
if ( cin.eof() ) {
  cout << "EOF" << endl;
}
if ( cin.bad() ) {
  cout << "bad, very bad" << endl;
}

If you use an arrow key, what happens here?
- loops a few times, then prints one of the exit messages?
- loops a few times, printing various fragments of the edited input, then goes back to waiting.

http://www.cppreference.com/wiki/io/fail

To get out of the loop, press ctrl-d, and you should see EOF printed.

If the code keeps in the loop, but prints various fragments of the line in several attempts, you should be able to recover.

Oh, and please find a way of copying the code accurately (pen drive, email yourself, whatever). It'll save a lot of confusion in the long run.

Salem 5,265 Posting Sage

Excellent first post - code tags, environment, statement of problem and example code. Everyone else should learn from this!

> strcyp (input1, default1);
Does this compile?
Isn't it supposed to be strcpy() ?

> the program will ignore (or seem to ignore) all of my "cin.ignore(1000, '\n');" and
> "cin.getline(input1, 31, '\n');" commands.
Or they could be returning error.
Check the return result to see if this is the case.

Salem 5,265 Posting Sage

"pong", for 4 players, over a network.

Salem 5,265 Posting Sage

line 23, trailing ;

Salem 5,265 Posting Sage
Salem 5,265 Posting Sage

How much research did you do between reading my reply and posting your reply?

Salem 5,265 Posting Sage

> will the first argument be the file name from which the program has been called?
Yes.
You can even use the registry to specify command line options if you wanted to.

Salem 5,265 Posting Sage

> What do you mean about not standard C anymore?
Meaning you can no longer pick a random C compiler (say for your Cray supercomputer or your mobile phone), and have your program work on all of them.

> Is it about making and using custom library?
Not necessarily. It could just be using the header files which describe the API of the OS you happen to be using. The Win32 API for example has many useful things which could be used to solve this problem.

Check out the console tutorials here
http://www.adrianxw.dk/SoftwareSite/index.html

Salem 5,265 Posting Sage

In the same way you count down the dots, count up in numbers.

Salem 5,265 Posting Sage

Without access to your platform, I've got nothing.

Apart from reading the manuals very carefully.
Focus on tcsetattr, tcgetattr and termios.

There may be some other thing you have to call, possibly right at the start of the program before you do any I/O (including printf).

Finding a forum specific to your platform may also help, if there is such a thing.

Salem 5,265 Posting Sage

Nope - http://www.daniweb.com/forums/announcement8-2.html
You make an effort, then we help.

Salem 5,265 Posting Sage
typedef struct{
        process *data;
        struct queue *next;
} queue;

The "struct queue" inside the typedef refers to an as yet undefined struct.

You need to name your struct, before you can point to it. Fortunately, this is easy to do, like so.

typedef struct queue_tag {
        process *data;
        struct queue_tag *next;
} queue;
Salem 5,265 Posting Sage

Which OS / Compiler are you using?

Sure it's possible, but it won't be standard C anymore.

Salem 5,265 Posting Sage

> mov==getch();
> if(mov='d')//supposed to be right arrow, don't know how to
You got them both wrong
= is for assignment (the first one)
== is for comparison (the second one)