Salem 5,265 Posting Sage

The first one is initialisation, the second one is assignment.

Arrays cannot be assigned in either C or C++.

You also need to get out of the "arrays are pointers" mode of thinking.
http://c-faq.com/aryptr/index.html

Vallnerik25 commented: He helped me by not only answering my question but making me think about it in a different way. Thus bringing about more questions but that's a good thing. Thx again. +1
Salem 5,265 Posting Sage

Picture if you will a young man, fresh from college with a nice degree, sitting in an interview for his first job.

Things are going well, he expertly answers the simple routine questions designed to filter out the flim-flam artists.

Then out of nowhere comes a tough question.
"So, what motivated you to choose that project, what problems did you face, and how did you overcome them?"
You've just entered - the twilight zone
Time warps into a haze, as you dimly recall all those threads from those 'mean' people who told you to DYOHW.

"Maybe they weren't being mean after all; maybe it was to prepare me for this moment. Oh why didn't I listen and take heed when I had the chance!!" you think to yourself.

Suddenly realising that your degree might be worthless, you blurt out without realising what you're saying:
"Some dude on a web forum told me to do it".

Yep, that'll impress - NOT!.

Even if you get the job, you'll only get asked "So, do you have any ideas how to solve this problem?" so many times before your colleages realise you're just dead weight.

Face it kiddo, you're on a career road filled only with exit ramps if you keep this up. Start doing what you're interested in.

jasimp commented: One of the best posts I've seen on the "do it yourself so you'll learn" mentality +9
Salem 5,265 Posting Sage

Sure, here you go

#include <iostream>
#include <string>
using namespace std;
int main ( ) {
  std::cout << "Enter a date" << std::endl;
  std::string input;
  std::getline(input);
  std::cout << "It's a Monday!" << std::endl;
  return 0;
}

It produces the correct answer 14.3% of the time.
Which coincidentally, is probably the same as the mark you would get if you handed it in.

Now that's symmetry for you.

mrboolf commented: lol +2
Freaky_Chris commented: LMAO +1
Salem 5,265 Posting Sage

Well if you got off your arse and actually posted a half-decent question, showing some actual effort, then you might get some actual help.

"I don't know and it doesn't work, and I haven't bothered trying yet" is not exactly a pot of honey we're all rushing towards.

No, it's just a big open-ended time-sink which could take weeks of effort to help with, given your apparent lack of knowledge.

My guess is you just hit reply in a hissy-fit, and have yet to click on the mysql link to do some reading, find some tutorials, try some examples etc etc etc.

> http://forums.devshed.com/c-programming-42/help-regarding-c-and-mysql-575397.html
I see you're not wasting any time just looking for other forums to be vague on.

devnar commented: Guess the net is a small place afterall. :) +1
Salem 5,265 Posting Sage

> ReadConsoleInput(stin, inputStat, 1, &NumRead);
How about
ReadConsoleInput(stin, inputStat, numEvents, &NumRead);

> delete inputStat;
How about
delete [ ] inputStat;

You should also check the console API calls for success/failure as well.

Freaky_Chris commented: Thanks +1
Salem 5,265 Posting Sage
Prabakar commented: Nice website lol +1
Salem 5,265 Posting Sage

> u didnt know what i mean?
Oh we know exactly what you mean. It's standard homework which any of the competent helpers here would have no trouble doing in less time that it takes to reply to your thread.

But that won't teach you anything like as much as you trying it for yourself. You can read all the cookery books you like, but until you go into the kitchen and actually burn things, or make things boil over, you're not going to know that much. Repeated practical experience is what counts.

> i tried to fixing this problem and i wrote some codes but it didnt applied.
> so i need some help
So post what you tried then!

mrboolf commented: great reply, as usual :-) +2
Salem 5,265 Posting Sage

"Can" - yes, lots of people here "can"
"Will" - probably not, it's your homework, you make an effort which is more than an exerise in copy and paste of your assignment.

http://www.catb.org/~esr/faqs/smart-questions.html

mrboolf commented: good answer - best link ;-) +2
Salem 5,265 Posting Sage

http://www.catb.org/~esr/faqs/smart-questions.html#urgent
Not to mention, the unindented code which is simply awful to look at.

William Hemsworth commented: Yup.. :) +5
Salem 5,265 Posting Sage

> Write a program that will do the following:
No, you read the forum rules first, then post some effort.

mrboolf commented: I completely agree. Well said! +2
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

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

b* means zero-or-more occurrences of b
And since even "hello" has zero or more instances of b, then it gets matches. This is somewhat different to the pattern matching for filenames at the command prompt.

If you want to match any b, then it's just 'b'
For 'b' at the start, it's '^b'

William Hemsworth commented: Good to have you back ;) +5
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

Well since you missed this:

Our Software Development forum category encompasses topics related to application programming and software design. When posting programming code, encase it in [code], [code=syntax], where 'syntax' is any language found within our Code Snippets section, or [icode], for inline code, bbcode tags. Also, to keep DaniWeb a student-friendly place to learn, don't expect quick solutions to your homework. We'll help you get started and exchange algorithm ideas, but only if you show that you're willing to put in effort as well.

Failed to read any of these threads:
Read before posting
The complete idiots guide to using code tags
Hey, dickwad, use the fucking code tags

And completely missed the watermark at the back of the edit window telling you about code tags.

Did you even press "preview" to check that you weren't posting a pile of fetid dingo's kidneys?

Sheesh - are you blind, or just stupid?

It's not just you. You're just the latest in an endless stream of barely sentient noobs who rush to the great white telephone and basically puke all over the floor of the forum. Do you think the regulars and mods have nothing better to do than offer janitorial services to the incontinent?

Swing by here at some point as well.

Oh well, that's my Jagged Little Pill for you to swallow, I'm going to carry on listening to Alanis singing the same - ha!

Aia commented: Code tags? What tags? I ain't seeing any code tags. +11
Salem 5,265 Posting Sage

How lazy would that be?
How many times did you follow this link?

@ddanbe
He's lazy, why recommend a book which has more pages that TIC++?

Accelerated C++ on the other hand is less than half the size. That might work.

On Laziness
But that only works if you're loaded with the others as well.

ddanbe commented: Like your suggestions on reading +1
Salem 5,265 Posting Sage

Just scope, that's all.

Inside main, only main() can call it.
Unless you copy/paste the prototype into other functions which need to call fun()

Salem 5,265 Posting Sage

GIYFS you lazy arse - we're not here to search stuff for you AND THEN email you the answers!
:@ :@ :@

Alex Edwards commented: XD +4
Salem 5,265 Posting Sage

> I was surprised, but this code compiled on Dev C++. I figured "or" would be an error
http://david.tribble.com/text/cdiffs.htm#C99-alt-tok

It's one of the less travelled paths through the C++ standard :)

VernonDozier commented: Interesting. Good find. +8
Salem 5,265 Posting Sage
R0bb0b commented: Nice forum guide +2
Salem 5,265 Posting Sage

Pah, a mere lightweight compared to Gv

Dave Sinkula commented: I'd forgotten about that one. :icon_razz: +17
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

> gives correct output so its correct...
Circular reasoning.
"correct output" just makes you lucky, not good.

> But if it seems that using fflush(stdin) in this required program doesn't make anything wrong
Only the requirement to use a specific compiler.
Like I said, your career will outstrip the lifetime of any single compiler.

If you want to learn a bunch of cheap tricks which "work for me", then go ahead, knock yourself out. But if you post it here as your "best advice", then expect people to crawl all over it and point out the problems with it.

In a 100 line program, you're going to get away with it.

In a 100,000+ line program, every time I've seen something of this scale ported to a new compiler, it's always a disaster area. All manner of sloppy "works for me" attitude all of a sudden generates errors by the boat-load. And even when you've got past all the compilation errors, there's another wave of far harder to find run-time problems just waiting to make a mess of your day.

> But for a small & simple program your writing a flush function(which may make code complex unnecessarily/tedious)
How is a function called "myflush", with ahamed's code in post #3 a vast burden?
It's 2 simple lines, and a function call, and your code is golden.

WaltP commented: Absolutely! +15
Salem 5,265 Posting Sage

6000 pages @ 1 page per day ~= 16.5 years.
Planning anything else afterwards, say the world's longest beard perhaps?

Now if you're doing some proper old-time research (and coming up with genuine new ideas, which is what a PhD ought to be), it might take weeks to come up with a single page of useful material.

But if you're planning on copy/pasting whatever google search results, it's doable.
But it would be the ultimate Write Once Read Never tome IMO.

The index would be so large that it would need it's own index ;)

William Hemsworth commented: heh x] +4
Salem 5,265 Posting Sage

Which compiler allows the nonsense "unsigned long double" as a declaration?

Alex Edwards commented: XD +4
Salem 5,265 Posting Sage

Spend a few weeks practicing with ncurses and drawning text windows, typing in one and echoing responses in the other.

Spend a few more weeks practicing network programming with beej to the point where you can send and receive messages (to yourself).

Then you might have a go at bringing the two ideas together.

Aia commented: Realistic goal; helpful answer. +10
Salem 5,265 Posting Sage
Salem 5,265 Posting Sage

It's that Y2K feeling all over again.
http://news.bbc.co.uk/1/hi/business/7660409.stm

Personally, I think one extra digit is a little optimistic.

scru commented: looks like you beat me to this one +3
Salem 5,265 Posting Sage

If you can't figure out from the first zip file that twofish.c is the algorithm, and tst2fish.c is a test wrapper with all the I/O you could ever need for it, then everything you plan seems beyond you.

happy8899 commented: Good!! +3
Salem 5,265 Posting Sage

Unless it's an array of chars, which if you regard it as a string, is conventionally marked at the end with a \0, then you're stuck.

Given void foo ( char *p ); Then

char a[10];
char *p = malloc( 20 );
foo( a );
foo( p );

As far as foo() is concerned, there's nothing standard to tell what kind of memory it is, or how big that memory is.

Further, this is also valid foo ( &p[5] ); which would almost certainly break any non-standard API which only worked on the result of malloc calls.

freelancelote commented: Thanks. The kind of answer I needed. +1
Salem 5,265 Posting Sage

Twofish is unpatented, and the source code is uncopyrighted and license-free

Gee, what more do you want?

Nick Evan commented: >"Gee, what more do you want" Haz you got winning lotto numberz lol 1? ;) +10
Salem 5,265 Posting Sage

> but removing the str = idNode + "\t"; seems to have fixed the segfault.
Yeah, idNode is an int, and "\t" is a string constant.

Which basically means a char at "\t"[idNode] Which is perfectly valid (if obscure) code, so long as idNode is actually zero, but would be increasingly way off the end of the array until (inevitably) you stepped off the end of valid memory and got a segfault.

Didn't you see lots of random garbage instead of the "nnn\t" you were expecting whilst testing this code?

Alex Edwards commented: Wow, that is a very subtle pointer-arithmetic issue come to light. +4
Salem 5,265 Posting Sage

Or without casts and tricky subscript maths

char (*st2)[133] = new char[st.size()][133];
for(int i = 0; i < st.size(); i++)
  strcpy(st2[i], st[i].c_str());
fn(st2, st.size());
Ancient Dragon commented: great suggestion :) +36
Salem 5,265 Posting Sage

http://www.talklikeapirate.com/piratehome.html

Here be a FAQ for ye all.

Q: What's your favourite data structure?
arrrray's me hearty!

Q: Which virus scanner do you use?
Avast!, and ye be free of the vermin.

Q: What's your favourite syntax?
Arrr, that'll be the main brace to keep your program on a steady course.

Q: What's your favourite programming language?
The language of the C you land-lubber!

Q: What should I do with memory leaks?
Fix them, lest your program become waterlogged and sink to Davy Jones' locker.

Q: How do you count your money?
Aye, tis the pirate way to use octal when counting pieces of eight!

Ezzaral commented: Arrr! Hoist the Jolly Roger, it be the 19th! +12
Salem 5,265 Posting Sage

> If you want to know what God thinks of money, just look at the scumbags he gives it to.
Indeed, when was the last time you saw a poor and destitute religious leader?

Sure, most of them will claim that it isn't theirs, but they sure bask in the glow of it's close proximity.

Ezzaral commented: Amen. Put your money on the plate please... +12
Salem 5,265 Posting Sage

Well no one will give you loads of money just because you think you're worth it. Without a good CV from well known companies (ie, people might be able to verify what you say), or an excellent online reputation at say elance or rentacoder, you're no different from the 1000's of wannabes out there.

Rates go up and down, so it's not a good idea just to choose what is "hot" at the moment, but go for what you actually enjoy doing.

Ezzaral commented: A dose of reality. +11
Salem 5,265 Posting Sage

Yes, they all give different errors.
But all ISO compilers should spot the same kinds of errors.

Another problem is you're computing sqrt(a) EVERY time around the loop, but the answer will not change from one iteration to the next.

> Does every compiler have different header files?
There's a standard set.
If your code only uses those headers, and is a correct program, then any ISO C++ compiler will be able to compile it.
Having multiple compilers on your machine is a great way of making sure that your code (and your knowledge) is really portable.

The best of the Borland compilers is probably this one
http://www.codegear.com/downloads/free/cppbuilder
Though they've recently started re-using the "Turbo" name for some new offerings as well. I don't know much about them yet.

vidit_X commented: Thanks Salem. +1
Salem 5,265 Posting Sage

http://clusty.com/search?query=osx+virus&sourceid=Mozilla-search

But if you take reasonable steps, like not surfing with admin privileges, not clicking on every single link in every spam message, and not purposely visiting every porn/warez site, your risk is pretty low.

There's a much bigger pond of windows / IE users to go fishing in, with plenty of them to catch.

Salem 5,265 Posting Sage

http://www.nondot.org/sabre/os/articles (down just at this moment).
There's a whole section of various file systems.

Alex Edwards commented: Thanks! =) +3
Salem 5,265 Posting Sage

> THANK YOU CAIA FOR YOUR REPLY. The program is work!!!
Of course it works!
Hundreds of people here "COULD" have given that answer in a few seconds, but that's not why we're here.

Did YOU learn anything about how to write the program?
Probably not. Sure, you can tell a C++ program from a hole in the ground, but that isn't much use.

But since you now seem to be bombing the forum with all your assignments without any effort, I guess you've pretty much given up on learning anything.
You're already behind, and now in free-fall away from the rest of the class.

In the next few weeks, the problems are going to get MUCH harder and you're going to be in no shape to even begin to tackle them unless you get off your arse and actually start posting some of your own code.

William Hemsworth commented: Well said XD +3
Salem 5,265 Posting Sage

Out the door, two doors down, on the left
You'll find DW's very own perl forum.

But to whet your appetite, read from a file, or stdin, and create directories

#!/usr/bin/perl -w
use strict;
while ( <> ) {
  chomp;
  mkdir $_;
}
Aia commented: Real man never ask for directions. Ha, ha. +9
Salem 5,265 Posting Sage

contact me at nobody@nowhere-we-care-about.com to let me know if the code worked.

Perhaps, who cares.

You didn't ANSWER THE QUESTION.
Any muppet can do it using > and <, but the trick is, can you do it with &, | and ^ ?

Nor did you read the copious (some would say deluge) of information which tells you to use code-tags.

jephthah commented: aha +4
Salem 5,265 Posting Sage

Some of the stuff on those 419 busting sites is hilarious!

That reminds me, I was selling some stuff online recently.
I only got two hits, both scammers.

So I told both of them to contact me on my alternative email address and just swapped the emails over. Then plonked them both in the kill file.

I just hope they wasted plenty of time trying to out-do each other before they figured out what had happened.

peter_budo commented: You are THE prankster +10
William Hemsworth commented: haha, that made me laugh :) +3
Salem 5,265 Posting Sage

> Career opportunities
Hard to pin down now, nevermind in several years time when you graduate.

> average pay of specific computer science fields
Again, depends where you are and what's flavour of the month when you need to start looking. What's hot today could be well out of date by the time you get to it.
Besides, you should go for what interests you, not what pays a few K more. Once your basic needs are satisfied, then job satisfaction counts for a hell of a lot.

> common programming languages used for each field
Yet another moving feast.
Find a college which at least has a course on software engineering. A short course in "language X" ain't worth squat IMO. It just churns out "hello world" programmers by the 1000's. The real skill is knowing what to do when confronted by a task which will take 10's of thousands of lines of code (and up into the millions). If you don't know how to solve that kind of task, then it really doesn't matter how well you can recite code fragments.
The thing of it is, when you get to those kinds of programs, there is a lot of work which isn't actually programming.

Also, the actual detail of your degree (and the final year project you did) only matters for your first job. After that, your degree is just a tick box.
"Do you have a degree, …

darkagn commented: Good advice all of it :) +3
Salem 5,265 Posting Sage

> >But 2004 was only 1.5 years ago :-)
> June 26, 2004 was the last post. It's now June 23, 2006.
Well silia55 really raised the bar on this one, by being well over 2 YEARS late with the useless bump, showing NO regard WHATSOEVER for the forum rules.

Move along, nothing to see here until lets say the 2012 Olympics roll around. That seems like a nice topical point to suggest at the moment.

It also gives some utter dimwit something to search for at the appropriate time, and dribble (like some Pavlovian dog) all over the dead post.

Alex Edwards commented: Way too funny... my ribs!... the pain!!!.. XD +3
sarehu commented: Your feats of self-satisfaction are psychotic. +0
Nick Evan commented: equalizer +8
Salem 5,265 Posting Sage

> AClass *inst = (AClass *) &ptr;
Probably the & here.

Alex Edwards commented: I agree. Without the ampersand it's just the address the pointer is pointing to, not the address of the pointer itself! +3
Salem 5,265 Posting Sage

> that will constantly read a record from a database.
Once a second?
Or maybe once a minute?

Make one (or several, for redundancy) the master which is responsible for reading the DB. When it changes, the master sends out a "UDP Broadcast" packet (or several, for redundancy) which basically says "do it now!".

All the other clients will just be waiting for messages to arrive, and performing the action when the message arrives.

Prabakar commented: Perfect Solution:) +1
Salem 5,265 Posting Sage

Well the last line would (probably) launch Excel on a machine where Excel was installed, and all the file associations were set up correctly.

Other than that, your analysis is good.

OmniX commented: Thanks for the support! +1
Salem 5,265 Posting Sage

Don't forget the change of units, otherwise you'll be hibernating rather than sleeping ;)

iamthwee commented: Amen sleep(3000) ain't the same in windows. +17