Salem 5,265 Posting Sage

> for (int z = 0; z < 2; z++)
Simply add for (int z = 0; z < 2 && j < i ; z++)

Salem 5,265 Posting Sage

The US at least is "fully loaded" when it comes to solar energy.

All it needs is a politician who isn't in the pocket of big oil to make a committment, and a hell of a lot of problems would be solved.

Take this recent SciAm article for example.
Sure, it's a lot of money, but it looks like loose pocket change compared to say the current Iraq war. How many more $1T+ wars is the US going to get into in the next forty years to "secure" it's drug of choice?

And it doesn't need all the complexity of sending stuff into orbit either. More than enough of the sunlight makes it down to the ground.

Wind energy is solar energy just one step removed.
Now if you could catch a hurricane, that would be something special....

Salem 5,265 Posting Sage

Well how well do you actually know Java?

Knowing a bunch of easy answers might seem like a good idea, and may occasionally get you the job.

Keeping the job on the other hand will require you to actually know your stuff, and not just have a good short-term memory for stock quiz answers.

Java is used in many industries, so what's important to mobile phone developers may be of no interest to database front end developers (say).

Salem 5,265 Posting Sage

> 1) I have a list of logins, seperated by a space (in a logins.txt file, like so: login1 login2 login3).
All on one line?
Or like
login1 login2 login3
login5 login5

You could try this

for i in `cat logins.txt`; do grep $i online.txt; done

For the other one, it would be something like

if [ -f $f ]; then
elif [ -d $f ]; then
else
fi
Salem 5,265 Posting Sage

> 2: Open Project/solutions-settings and add the include and library-folders to the list.
You also need to add the library name(s) as well to the list of additional libraries (also on the linker settings somewhere).

Salem 5,265 Posting Sage

What about
date '+%s'

Salem 5,265 Posting Sage

"This directory contains the source code and shell scripts necessary to convert SEGY files to ASCII format and to create postscript plots, along with a makefile and a README file."

I found that with an obvious web search.
Is it what you want?
Can you guess what I typed?

Salem 5,265 Posting Sage

> Data = new string;
Not only does this leak memory, it also loses all your previous input.
You need a way of expanding your array of lines.
Have you considered that std::vector would be ideal for this.

Put the cin.ignore directly after any I/O functions which leave newlines behind.

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

> while (!myfile.eof())
http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1046476070&id=1043284351

Use while ( getline(myfile, line) ) Try it with a small text file (say 5 lines) and note the difference.

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

Well that would depend on how "string" is declared in your C program.

Salem 5,265 Posting Sage

Function pointers need more ( ) vector<bool(*)(int x)> rules;

Salem 5,265 Posting Sage

Congratulations :(
Not only did you fail to read HOW TO POST CODE in numerous places, you've also spoon-fed an answer without the OP having to do a bloody thing for themselves.

So now they're just going to run off with their nice bone you've thrown them, hand it in for high marks (possibly) and with the delusion that either
a) they can program in C++ (they can't)
b) they can always rely on some schmuck like you too eager to help (possibly true).

Salem 5,265 Posting Sage

You missed this on your way in
We only give homework help to those who show effort

> I don't know to write this program because I'm new using C++
Did your previous assignment cause as much trouble?
Or did you get someone else to do that for you as well.
Hint: read up on for loops.

> can somebody help me??
http://www.catb.org/~esr/faqs/smart-questions.html#prune

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

Without seeing some source code, there's not a lot we can do except admire your artwork.

Salem 5,265 Posting Sage

Do you call any other input routines like say scanf ?
Because that can mess you up as well.

Eg.

scanf( "%d", &myint );
fgets( buff, sizeof buff, stdin );  // this will "appear" to be skipped.

Ideally, you should use fgets() for ALL input, then use say sscanf(), or whatever else to parse the input.

But in the absense of that, try calling this between scanf() and fgets() calls.

int skipToEOL ( FILE *s ) {
  int ch;
  while ( (ch=fgetc(s)) != EOF && ch != '\n' );
  return ch;
}
Salem 5,265 Posting Sage

It's probably to hide from the casual snooper, not someone who knows what they're doing.

Salem 5,265 Posting Sage

Probably the "\n" which is at the end of the line returned by fgets().
Remove the \n (plenty of examples of how to do this are around).

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

Try a search engine.

Salem 5,265 Posting Sage

Good luck :icon_rolleyes:

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

Rule 1 - don't spam the crap out of the net with your cross posting
http://www.catb.org/~esr/faqs/smart-questions.html#forum

Already answered here - http://cboard.cprogramming.com/showthread.php?t=106619
If a forum doesn't deliver, then you're free to move on. Broadcast spam like this just pisses people off.

Rule 2 - read ALL (not as in your case, NONE) the posts on HOW TO POST CODE.
This tells you to use code tags - http://www.daniweb.com/forums/forum2.html
So does this - http://www.daniweb.com/forums/forum8.html
Wait for it, wait for it - http://www.daniweb.com/forums/announcement8-3.html
You're not going to believe this - http://www.daniweb.com/forums/thread78223.html
And not forgetting the watermark at the back of the edit window.

Salem 5,265 Posting Sage

<vader>I sense a presence on the forum, which I've not sensed since.....</vader>

> Generate a set of test inputs and expected results for the Currency Conversion program.
Starting with an example "good" input and some examples of bad input (you ask for an integer, you type in "hello" say).

Salem 5,265 Posting Sage

> Last edited by LiquidScorpio81 : 43 Minutes Ago at 18:45.
It's a shame you didn't add the code tags.

"Hey, I know, lets piss off all the people who help around here by continually posting unindented crap."

Doesn't work kiddo. Either we ignore you, or just report the post and wait for a mod to show up in a few hours. Then, if we're still interested, we might just get around to looking at your missive.

Either way, what could have been answered straight away is now delayed until your post gets fixed.

Salem 5,265 Posting Sage

Do you have to do it in C?

Because it's like a 5 minute job and a handful of lines of code in say Perl.

Salem 5,265 Posting Sage

General comments:
1. The indentation needs work.
2. Lower level functions should just return results. Maybe I just want to search, WITHOUT print the result AND clear the screen.

> void random(int []);
Well named variables in the prototype will help document the API. What we've learnt so far is nothing. OK, big deal, it's an array. And....

Say
void random( int arrayToFill[] );

> srand((unsigned)time(0));
This should be called ONCE, in main().
Calling it multiple times adds nothing. Calling it in a loop would be a disaster.

> for(int x=0; x<100; x++)
And all the trouble you went to to declare SIZE.
It would be a lot better if you passed size as a parameter to all these functions receiving an array.

The entire "do..while" in main could be a separate function. main is starting to look busy.

Salem 5,265 Posting Sage

You declare your strings as char arrays.
When you pass your strings to a function, they will be compatible with "const char *" without you having to do anything special.

Just look at how you use strcpy() for example.

Salem 5,265 Posting Sage

Do you have a specific test case?

Are you sure it's not something like
1234567 being displayed as say 1.23456E6 (for example).

Salem 5,265 Posting Sage

Any particular "brand" of "unix"?
An awful lot of things claim to be "unix", even many things which only look like "unix".

Salem 5,265 Posting Sage

Say you have void foo ( const char *param ); You can call it with ALL of these

char buff[100];
const char cbuff[] = "hello";
char *pbuff = buff;
const char *pcbuff = cbuff;

foo ( buff );
foo ( cbuff );
foo ( pbuff );
foo ( pcbuff );
foo( "hello world" );

In the context of a function formal parameter (or a prototype), what it is telling you is that the function will NOT change it.

void bar ( const int *p, int *q ) {
  *p = 0; // NOT allowed, p is a pointer to const
  *q = 0; // this one is OK
}

It means that whatever was in your array before the call will still be there after the call.

What you call it with doesn't have to be const as well.

Similarly, when you call a function expecting an int pointer (for example), then this is what it usually means

int result;
func ( &result );

Now you can declare a pointer it you want, but you need to initialise it.

int result;
int *pa = &result;
func ( pa );

But this is definitely wrong

int *pa;
func ( pa );

Wherever you have a pointer, you need to be thinking about where the memory is, and have you initialised it to point to some suitable memory. Simply declaring variables with the correct type will keep the compiler from complaining (sure the types are …

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

Nevermind the database, you need to work on the basics of C programming.

> int main((int argc, char *argv[]){
Mis-matched.
You didn't even compile this before posting did you.

> fflush(stdin);
http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1052863818&id=1043284351

> gets(opt_host_name);
http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1049157810&id=1043284351
Not only that, where is opt_host_name pointing?
Answer - nowhere.

Practice reading input using char arrays and calls to fgets() for a while.

Salem 5,265 Posting Sage

> int ar[100];
But if you write the code on this day, it would be int arrrrrr[100];

Salem 5,265 Posting Sage

Zip is about as primitive as it gets.

Salem 5,265 Posting Sage

Yes, faster to the first bug than almost any other language.

#include <std_troll.h>

Salem 5,265 Posting Sage

#define _CRT_SECURE_NO_WARNINGS Put this at the very start of your program - the first line in fact.

> error C2087: 'numbers' : missing subscript
> void getArray (int numbers[][]);
You're only allowed to leave the left-most one empty.
All the other subscripts need a size.

> space[x][y] = false;
What are x and y initialised to at this point?
If it's garbage, then your program will blow up.

> for (i=1; i<size; i++)
Was it your intention to leave the top row and left column uninitialised?
Arrays start at 0, not 1

Salem 5,265 Posting Sage

I assume you're talking about plugging a device into a standard desktop machine running say Linux or MacOS, and you want to record when the user logs off the desktop machine.

This is a pretty good hardware site.
http://www.lvr.com/

Salem 5,265 Posting Sage

You test it by giving someone else (to read)
- the requirements (which in this case would be your homework assignment)
- your pseudo-code

Bascially, you're looking for
- have you got everything
- does it make logical sense
- is it well structured

If your "code" was machine-readable, it would cease to be "pseudo" at that point.

Salem 5,265 Posting Sage

There's just no helping some people.
What part of USE CODE TAGS is confusing you?

Does it look something like this when viewed on your system?
Specifically, note the indentation which helps you figure out the flow of the code.

if [ "$LINUX_PLUGIN" = "" ] ; then
  if [ ! -r "$PPPOE_PIDFILE" ] ; then
    echo "adsl-status: Link is down (can't read pppoe PID file $PPPOE_PIDFILE)"
    exit 1
  fi
fi

> for i in /etc/ppp/ppp*.pid /var/run/ppp*.pid ; do
Read the comment, what do you think it does?

Try this on your command line for i in /etc/ppp/ppp*.pid /var/run/ppp*.pid ; do echo $i ; done > IF=`basename $i .pid`
Back-ticks collect the output of a sub-command, and store the result in a variable.

Try this command basename /foo/bar/hello.txt .txt Then try this command man basename > netstat -rn | grep " ${IF}\$" > /dev/null
/dev/null is the trash can for output you're not interested in.
It's typically used when you're just interested in the success/fail of a command rather than the detail of the output.
Here, we're just interested in whether the netstat command has produced a particular output.

Salem 5,265 Posting Sage

> Alas, I have no time to inspect your code more carefully now.
Take your time, it was posted (and abandoned) on 8th Jan 2005

Salem 5,265 Posting Sage

Since there is virtually nothing in common (different compiler, different operating systems, different eras), it's very hard to make an objective comparison based solely on one small test of one aspect of one feature of the STL.

It might be an order of magnitude, but it's still the blink of an eye (in human perception terms).

Also, the STL only makes statements about complexity, not performance. If you try your test with 3000 elements and 300,000 elements, you might get a different ratio of performance.

> Do you think that an old compilator can differ a magnitude order from the new one?
Apparently, it can. More inline code, better optimisation and a better allocation strategy - yeah, perhaps it could.


As for your last question, Visual Studio Express is
a) far more up to date
b) far more standard compliant
c) $0 in price.

Salem 5,265 Posting Sage

A couple of things.
1. VC6 is probably 10 years older than your Linux compiler.

2. Have you considered using reserve() to allocate all the space up front, then just subscript your accesses (rather than push_back)

Salem 5,265 Posting Sage

> Can I boot/run the XP HD (master) and access the W98 Hd (slave) to transfer/copy files?
Sure.
Just make sure the W98 disk is configured as a slave drive when you swap them over, and it just becomes a data disk.

> Assuming this can be done, how would I strip/reformat the WIN98 HD? FDISK?
Yeah, FDISK would do the trick.

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

I've got to ask why you feel the need to do this...

Salem 5,265 Posting Sage

What you have IS pseudo code.

But you didn't say what was missing, therefore it's impossible for us to "finish" it.

Salem 5,265 Posting Sage

Looks perfect to me, what's the question?

I should say, what's the requirement. Because without that, the post is meaningless.
I mean, I could guess this is a currency conversion program (in which case, it's pretty good). But if it's for a game of chess, then it's rubbish.

Consistency perhaps?
Select Case of currency Type
Case 1:

Select Case of currency Type
Case CANADIAN: