WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

And why are you claiming console apps are not programs? How do these definitions not fit a console app? :icon_wink:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You do not want your variable to be static .

Set lowest_int to the first value in the parameter list, then check all the others.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

None. I know, I'm a heathen....

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

gerard, please don't fix people's code for them with no explanation. They learn nothing.

solitude_spark, the problem is you specified #include <file1.h> . The <brackets> tell the compiler to look in the compiler and system directories but not in the current directory. To search in the current dir use "double quotes" #include "file1.h" .

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Interesting that people believe the alleged separation of church and state exists. Are you unaware that when after the country was founded, a prayer was said at the opening of a Congressional session? When did this practice stop?

If there is a separation, how do you explain this, this, and this? Hypocrisy?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Write to a file.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What input functions are available with ncurses?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Set up another array of 16 (say ptr ) with values from 0-15, randomize that array. Then you access the dice array:

r = random value (0-15)
dice[ptr[r]][x]
rkulp commented: Thanks for the help, it was exactly what I needed to know. +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

does anyone know how to make an array search for how many words are in it?

Yes... I do.

See the end of your last thread.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

here is the final code still writting i have to write a sentence and write a phrase that will count the words, but i don't know how to do that either

Well, think about what you are trying to accomplish -- what is a word, what is a sentence, things like that. And write TEST code to see how cin really works when reading letters, words, sentences. It will be an eye opening experience, and you will be surprised what you're going to find out.

Now, for your code:

//Ask the user to enter a phrase
	cout<<" Please enter a word no more than 5 letters and I\n";
	cout<<" will display it backwards.\n";
	cout<<" ";cin>> line;

	//Display the line they entered backwards
	cout<<" Here is the word you entered backwards.\n";
	cout<<line[4]<<line[3]<<line[2]<<line[1]<<line[0]<<endl;

That's your solution? Sorry, but with all the help we've tried to give you, it's really lame. And I hope it's not what your instructor wants.
Post #7 by you kind of states one thing, and I concurred in post #36. Then you wimped out.... :icon_wink:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Oh No!!! Not the String/scanf() faux pax!!!!

scanf("%s",name);
                        scanf("%s",state);
                        scanf("%s",rating);

Please read this

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

lol but in seriousness if you need help im not sure if this site has pm i just joined but if it does feel free to use it.

No.... Please post in the forums. The idea here is for everyone to learn, not have little discussion groups behind the scenes.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I think strings behave a bit better with cin than char arrays.

I'm not so sure about that... They seem to be pretty much the same to me.

If he/she was already using strings in his code he/she should continue using them.

Very true...

Is there a specific reason that you are using a string instead of char array? It would be easiest with an array because of how you can manipulate it

using strings is nice but not needed but somehow everyone started to veer towards using strings instead lol

Probably because in C++ char arrays are necessary at times, but strings are somewhat more standard and have more functions(methods) to deal with them easier. They are also dynamic. As for this type of manipulation, either string or char array is just as simple.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

finally got it you guys thank you so much. I needed the << in between the line[4] and line[3] etc. I know it's probably the long way around but I'll get better at i go along. But thanks so much glad I found you guys.

In my opinion, you should create a new copy of the reversed string then output it, not just output the original char by char backwords. You learn more that way.

Also, please post your final code. We'd like to see how it finally ended up.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

got this error when I put in that code

error C2064: term does not evaluate to a function taking 1 arguments

Psychic???? :icon_wink: What's "that code"?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

just a quick question. there is a string array? or is the type itself just an array that is managed by a class?

You can have a string array -- but no there is not really a 'string array'. You are correct in it's an array managed by a class. string EmployeeName[100]; is a string array.

EDIT: sorry for double post. :(

Double posts are fine if you have something to add....

please don't laugh at my code I not very good at this.

there's nothing to laugh at. It doesn't do anything...

I changed line into a string just now and got an error while in the dos screen when i was testing the program.

Yes, always explain in full what's happening. We aren't psychic. If you don't give us enough info, you just may get the response "you must have done something wrong then" and that's it.... :icon_wink:


And don't forget the code tags!!! They're only explained:
1) in the Rules you were asked to read when you registered
2) in the text at the top of this forum
3) in the announcement at the top of this forum titled Please use BB Code and Inlinecode tags
4) in the sticky post above titled Read Me: Read This Before Posting
5) any place CODE tags were used, even in responses to your posts
6) Even on the background of the box you actually …

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

No, you don't wan tto use the reverse() method. You learn nothing by letting the compiler designers do your work for you.

1) Do you want to reverse the word into a separate string?
2) Or do you want to reverse the the string in place?
If (1), just loop through the string from the back to front and copy each character into a new string. (2) is just a little harder - you have to work from both ends at the same time.

3) Are you using string or a char array? The only real difference is the functions used: string.len() vs strlen() for example.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I showed you how it works for hh:mm:ss from seconds.
Your task is to do weeks, days, hours from hours.
It's the same procedure with different numbers. How many hours in a day? How many hours in a week?

Simple as that.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Take for example you want to convert 7520 seconds into hh:mm:ss. Use integer math
To get hours: hr = sec/(60*60); // int math truncates What's left is: sec = sec - (hr*(60*60)); // remove the #hrs Or using mod: sec = sec % (60*60)); // gives remainder if hrs divided out From here you should be able to do minutes, then figure out how to do your project. It's the same.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Private members cannot be output directly because they are private to the class. Nothing outside the class knows it exists. Create a method that returns the value and output via that method:

int getVariableName()
{
    return VariableName;
}

cout << getVariableName(); And please learn to format your code better now. It helps us follow your program and later, as your code gets more complicated, so will you.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I couldn't see how changing ' to " in an HTML IMG and BUTTON tag would affect what a button passes into the form, but I tried it. No dice. Result is the same.

And yes, %22 is ", which I missed. Thanks. Now the question becomes
why does the imgnam parameter become the SRC parameter of IMG tag rather than the value of the VALUE param of the BUTTON tag?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I am new to C programs. I have tried to write the code for game of life. I started with just the first part. But its still not done. There are some errors. could you please point out where I am wrong?

Here are the first places where you are wrong:
1) Not using Code tags
2) Expecting us to find your errors when you already know what they are
3) Not reading the Forum Rules and the Sticky Posts.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I have the following code in a form:

<?
                    for ($n = 0; $n < count($filelist); $n++)
                    {
                        printf ("<button type='submit' name='imgnam' value='%s'>", $filelist[$n]);
                        printf ("<img src='%s' width='100' />", $dirname . $filelist[$n] . ".gif");
                        print   "</button>";
                        printf ("<br>%s</p>\n", $filelist[$n]);
                    }
                ?>

$dirname contains the directory value $filelist[] contains all .JPG file names found in the $dirname directory

This generates the following HTML code:

<button type='submit' name='imgnam' value='File0001'><img src='./Lemmons/10-24-91/File0001.gif' width='100' /></button><br>File0001</p>
<button type='submit' name='imgnam' value='File0002'><img src='./Lemmons/10-24-91/File0002.gif' width='100' /></button><br>File0002</p>
<button type='submit' name='imgnam' value='File0003'><img src='./Lemmons/10-24-91/File0003.gif' width='100' /></button><br>File0003</p>
<button type='submit' name='imgnam' value='File0004'><img src='./Lemmons/10-24-91/File0004.gif' width='100' /></button><br>File0004</p>
<button type='submit' name='imgnam' value='File0005'><img src='./Lemmons/10-24-91/File0005.gif' width='100' /></button><br>File0005</p>
<button type='submit' name='imgnam' value='File0006'><img src='./Lemmons/10-24-91/File0006.gif' width='100' /></button><br>File0006</p>
<button type='submit' name='imgnam' value='File0007'><img src='./Lemmons/10-24-91/File0007.gif' width='100' /></button><br>File0007</p>
        </td>

7 buttons are displayed, each with a GIF image. When a button is clicked (ex: button for #0005), FireFox and Safari both show $imgnam contains the value field of the button clicked, as it should -- in this test case it contains the value File0005 .
IE on the other hand does not. When I display the value of $imgnam a broken image box is displayed with the properties:

Name:       %22
Address:    http: //www.pattinson.net/%22./lemons/10-24-92/File0005.gif/%22
Size:       Not Available
Dimensions: 100 x 114 pixels

Any idea where this %22 is coming from? What does FFox know that IE doesn't?

The effect of the code can be seen here with values displayed for debugging purposes.


The full code:

<? 
##--------------------------------------##
## mainline
{
## These lines display the values coming into the …
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

use Wine?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Does the motive for starting a thread make a difference to the help that should be offered? I'm a hobbyist, so any help passed in my direction will not make me any money or help me pass any examinations.

No, your motive should not be a factor -- unless the motive is for someone else to write the program for you. Whether a student, hobbyist, or professional, IMO you should ask an appropriate question, and give enough detail so someone can point you in the proper direction. We are not a coding service, and it bothers me when someone hands out code willy-nilly. If you are asking a question, you are willing to learn. If you aren't willing to learn, there are a lot of other sites where you can have someone write your code for you -- for a price (and there should be a price).

Am I (attempts at solving the problem myself aside) more or less deserving of help than somebody with a critical interest (e.g. somebody in the IT business or a student)? Is this even relevant - should help be provided piecemeal (even cryptically) regardless of the motive?

Irrelevant.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Somebody forgot to read the Forum Rules as requested multiple times upon signing up.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I suppose you're right. What I mean -- now that you've lambasted me :icon_wink: is that sonce the functionality requires nonstandard techniques, without knowing what the instructor had in mind (taught) we will very possibly come up with a solution that either cannot be done with the compiler in use or is too advanced and uses functions that are unacceptable to the instructor. IOW, we haven't enough information to suggest a nonstandard implementation. ne?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

When you pinch a clone does he not cry? When you tickle a clone does he not laugh? When you cut a clone does he not bleed ? Does he not have fingerprints, or finger nails that grow, or hair that grows?

Don't know. Never met one. :icon_razz:

However they still are organisms but a low level organism and what does that describe - animals.

How so? Who has defined them as low level? What does that mean? And do they agree with you?

However if every organism was treated as a human then there would be no problem with producing clones.

Well, there goes Cancer research, disease control, pest control. Our world will be a better place when dangerous bacteria can run rampant because, as an organism, it's treated as a human. And mosquitoes...

Except there is one difference between lions and humans - intelligence.

And clones have no intelligence...


Animals don't have 'rights'. They don't vote. Humans can place restrictions on treatment by humans, but they cannot bestow rights on animals. It's ludicrous.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

For some reason Daniweb decided to double post that for me :-O

Daniweb must have thought it was worth repeating :icon_twisted:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

In standard C++ you can't. If your compiler is one of those that has enhancements, there may be a way, but it's non-standard and therefore not recommended.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

"To be is to do"-Socrates

"To do is to be"-Jean-Paul Sartre

"Do Be Do Be Do"-Frank Sinatra;

Salem commented: yaba daba doo - Fred Flintstone :) +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Because that's not how C++ was defined.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Sign at the End of the Universe
thanks to a story by Duane Ackerson (1974)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Maybe a "Disk Controller"? Or maybe "A Board that breaks my computer when it's removed"...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I have a problem with this topic ..Solution to algorithm using static and dynamic data structure

I have a problem with this topic too. There is no solution to the stated problem.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Mostly FFox. Once in a while Opera. IE only when I have to (maybe 3x a year)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Perhaps 20% of new users in the php forum. However they/dani missed a spot. When you reply to a 4 year old topic and your not signed in I don't think there is the code tags message in the textbox. So yea that is where the problem with the code tags lies.

a) I'm more familiar with C/C++. and it's more like 80-90%.
b) You cannot post without being signed in. Try it.
c) I just looked at the very first post in the PHP section. The Code tag message is in the text box.

[pedantic]
And
-- your is possessive -- it's your problem.
-- you're is the contraction of you are
FYI :icon_wink:
[/pedantic]

iamthwee commented: Genius! +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

By keeping track of your spacing with a variable.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

The statement cin>>phy_name[i]; reads a single character -- phy_name. You need to read the entire string using cin>>phy_name; Adding the subscript references the i'th character only.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Didn't realize it had been tried and failed before. If announcements don't work the only thing I can think of is having above the message box where they type their post is a cartoon providing these messages. That is a long shot but I'm clueless.

Information about CODE Tags is actually written on the background of the message box where they type their message! Any guess as to the percentage of new posters that miss all 6 (at my count) places the tags are mentioned?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

My guess, since you didn't post any actual code, is you're reaching G>291 and/or L>2

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Did you forget to read the Rules and the post Read This Before Posting?

How about all the information on CODE tags like
1) in the Rules you were asked to read when you registered
2) in the text at the top of this forum
3) in the announcement at the top of this forum titled Please use BB Code and Inlinecode tags
4) in the sticky post above titled Read Me: Read This Before Posting
5) any place CODE tags were used, even in responses to your posts
6) Even on the background of the box you actually typed your message in!

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

My suggestion? Make a general "Read before posting" sticky ...

You mean like the announcement We only give homework help to those who show effort and the sticky post Read This Before Posting? What a good idea! Think that will help? :icon_wink:

They don't seem to help in the C/C++ forum...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Or loop through the 'char' and use the num = (num * 10) + char process.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

OK. I corrected the CODE tags. Now what?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Ummmmm, OK, I'm really missing something....... How do I post on Daniweb??????

I would guess exactly as you did here.

iamthwee commented: LOL +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You should have specified that 14 hours ago! What you posted has only one space...

Use fgets() . It can read exactly x number of characters. Or use strncpy() to move the fields after reading teh entire line. But scanf() functions aren't smart enough to read the format you want without a very confusing format specifier.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Another thought -- is the file actually formatted like

34012 Philip Morris                 Lisbon    Milan      01

with all the spacing?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

scanf() functions cannot read past whitespace. Therefore
34012 Philip Morris Lisbon Milan 01
is 6 fields, not 5.

How can scanf() tell between
"Philip Morris" Lisbon Milan
Philip "Morris Lisbon" Milan
Philip Morris "Lisbon Milan"
?

Read each field (ID, Fname, LName, Depart...) and combine the name into your NAME field.

But then you have the problem of:
3124 Johnny Van Zant New York Los Angeles 07
If you can guarantee that name is only 2-words and arrive&dest are 1 each, the above should work.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Not in standard C nor C++. It requires functions that are not part of the language, but some systems and compilers have enhancements that could allow it.