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

That seems reasonable, but what if the buffer is 20 characters and the user only enters 4 and hits enter?

What would the value of strlen() return in that case?

jonsca commented: Yup +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What seems to be wrong? It really helps to explain the problem.

And if you made changes, you need to post the new code. You might also want to post just the part that has the problem.

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

Actually, 13! is larger than the maximum size your variable can hold. That's why it doesn't work. Nothing to do with ASCII 13.

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

Neither lol.

int i;
for (i = 0;array[i] !='\0';i++)
{ 
    if(array[i] =='\n')
       array[i] = '\0';
}

Or maybe:

l = strlen(array)-1
if (array[l] == '\n') array[l] == '\0';

Saves a for loop.

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

First thanks to both of you for your help.

Sure. Did you figure out what was wrong with 13? What was it?

Second i did the code by my own and it works somehow.
It´s not like i was asking for everything :-P
I just need little help by these 2 parts. I guess this will be okay by the teacher.

I was not suggesting you wanted someone to write your code. What I was saying is that by using someone else's code that you don't understand in your code, your instructor may believe someone else wrote it all. Keep your code at a level you understand.

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

Oh yeah...I was going to say that, too. Don't use goto.

And, you can't actually control what the user will input. But your program can handle it if they do not enter what you want them to, if you add the code I suggested. :)

And he can fail the project for using code that was not taught and has no business using. The instructor will know that the code was given to him and he's getting others to write his code for him.

Please keep in mind who is asking and their level of knowledge before showing your prowess as a programmer and blowing their mind with higher level techniques. :icon_wink:

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

1) Are you certain the program is handling 13! correctly?

2) Not easily. Do you understand how to parse strings? If so, you can try it. If not, you might want to wait a while to handle that.

3) Do not use goto . It is considered bad programming practice since a loop can easily be used instead and to better effect.

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

Look up Comparison operators in your book. It's best to check your book when someone makes a comment -- however cryptic -- and not just post back "I don't know".

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

main()
{
    //declares an array of strings    
    string item_name[number_of_items];
    
    cout << "How many items does the customer have? \n";
    cin >> number_of_items;

When you use number_of_items, what value does it have? How large is the array?

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

Do you see a problem with if (minute = TimeToAlarm[g]) ? Is the comparison correct?

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

Also , I it seems too common that people [that reply] always state the problem and never give solutions to it , frustrating ...
[solution: state the solution to problems you replay to in your posts before you click "post"]

It also seems too common that people [that ask Q's] rarely state the real problem and never give enough details to understand it , frustrating ...
[solution: state the problems clearly with details and don't post 400 lines of code when 20 would do. And click PREVIEW so you can verify your problem is clearly stated before you click "SUBMIT"]

Try reading posts to HELP sometime.

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

Also, you did not start the program by defining a console program.

_tmain() and stdafx.h are not standard and supplied by VC because of the type of program you told it to create.

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

The thread-revivers are usually either spammers or, more often, a newbie who is trying to help and isn't noticing the dates. I'm guilty of several of those myself, I think. They tend to get pounded a bit harshly in my view. First post, trying to help, and they get told that they're an idiot for reviving an old thread.

Maybe so, but if there are 1000 pages of threads, and you are looking at page #500, you'd think the post is not current. Especially when the 1st page has maybe 2 days of posts.

Frankly I think reviving an old thread can be useful sometimes. Maybe you have something to add that wasn't mentioned and the thread provides a good segway into it.

Yes, but that 5% that are useful if someone cares later are over shadowed by the other 95% that are:
1) "I have this problem, too"
2) "Here's some really bad code that doesn't really answer the question"
3) "Nice post"
etc.

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

It sure would be nice if links were posted :icon_rolleyes:

Compilers
Code::Blocks
MSVC++ Express
Open Watcom C++/Fortran
Bloodshed DevC
Turbo C++ Explorer 2006

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

Ahhh, I deciphered the question, which is
Keeping the textbox visible, can the contents of the box be invisible...

Yes, set the background and foreground color of the textbox the the same value.

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

The only thing I can't get to work is the countValue function.

...
//count the number of occurrences of each number in the linked list
Node* countValue(Node *pHead) //<------HERE'S THE PROBLEM
{
...

So you don't think actually explaining what the problem is could be important? Pointing to a line is enough?

Please reconsider...

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

Here you go:
Why scanf() is bad

If you haven't been taught anything but scanf() , you must live with its idiosyncrasies until you are taught something better. Bulletproofing input is not trivial and you don't seem to be ready for it's complexities. Give it a few weeks.

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

Any ideas?

Yeah I do, but you won't listen.

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

Functionally identical means they will both overwrite memory with wild abandon and laugh at you when your program crashes. And there's nothing you can do to prevent them from doing it.

jephthah commented: haha +6
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I suggest:

infile.open("C:\\pathnameToFile\\charsfile.txt", ios::in | ios::out);

to make sure you can see the file during development.

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

Please use gets() instead of scanf() if you expect spaces in the user input. scanf() does not handle spaces the way you want it to work.

gets() is not an option, because there's no way of controlling how much data can be inputed. There's no way of using it safely.
scanf() is an option to read input string, but a mischiefing one.
A better option to read string input would be fgets().

gets() and scanf("%s", ...) are functionally identical. See this to understand why you never use either.

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

You're close.

This code if((array2[i] <= 'a') ||(array2[i] >= 'z')) says
If the letter is ('a' or less) or letter is ('z' or more) ... Is that what you want?

Rethink this if statement. What are you really trying to look for?

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

it if LEN(textbox1.text) = 0 THEN Msgbox("Please...")

I repeat, "But what if there are SPACEs in the text box?

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

Completely worthless description without context. Start at the beginning, not the tail end of the problem. Remember, we aren't there watching how you got to this point.

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

But what if there are SPACEs in the text box? How about using If trim(Text1.Text) = "" Then to be sure.

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

Why is it new people always think that "something is wrong" is an explanation of the problem? If you take your car to get fixed, will "something is wrong" be enough for the guy to correct the problem?

Details! What is wrong? What did you expect to happen? What actually happened?

And clean up your formatting! the code is a mess and hard to follow. See this.

And yes, it's true. You can't

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

I don't understand the problem. If you have the word in a database, and they type in the word, it seems a simple matter to compare them. What are you leaving out of your description?

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

Please format your code so we can see the flow. Your indenting is too inconsistent to follow. You claim it will not loop. With about 10 loops can you be a little specific?

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

In Borland 5.5 is erases the input.

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

Then you did it wrong.

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

Whether you have a good length or bad, you run the for loop outputting n characters of whatever happens to be in a

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

I don't see a problem. Maybe you need to post some details about the "sometimes".

By the way, I would get rid of the while and change the if statements into while statements. Do all the seconds at once then move on to the minutes.

[edit]
Oh.
You always subtract 60 from the seconds. You did not put the statements in a block using { and }

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

Can you try to give some details? Like where the problem is, what values are involved, what garbage characters. Without details we have no idea where to start since we didn't write the program.

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

Ahh, using nonstandard I/O functions. Try it without getch()

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

That works fine with Fbody's changes.

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

Try if (key == 27)

Has that worked for you? How?

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

@ firstPerson

thanks for your suggestion..
I did like this.. but in this way, every space is also counted as character and plays role in comparison whereas I would like to compare only words. e.g. if 3 words out of 5 are correct, it should reply correct.

----
Any more suggestions are welcome.

I assumed when you made the above comment about SPACEs, you corrected the code to ignore SPACEs. What other suggestions do you need?

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

Don't put it in the switch.

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

or...

textunit.SelStart = Len(textunit.Text)

This is a much better solution...

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

The book should show you examples, doesn't it?

Make a file called counter.h. Put the entire class definition in it. Erase the definition from the C++ code file. That's all there is to it.

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

Please stop bolding your messages. If you look through these forum, you will not see messages in bold.

You start the loop just above the first line you need in the loop. That varies with every program. Usually above the initialization of values that must be set every time thru the loop, above a menu, that type of thing.

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

I imagine that the "forum police" would agree with me.

We do. This thread almost got closed.

Clean up your attitude, faaz. You get more help by being thankful than being belligerent .

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

Look up the difference between int and char
Look up how an if statement is designed
Look up how to specify a character value vs integer value vs string value

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

Posting Questions Lesson number 1:
"This is wrong" doesn't cut it. What is wrong? Always provide details. Only you know what happened, so you need to tell us
a) what happened
b) what should have happened.
Remember, we cannot see your screen. You need to post all information that is needed to figure out the problem.

In this case t and f are variables. You want characters 't' and 'f'

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

Consistent formatting will solve these problems in moments.

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

I don't see a problem. Maybe you should post the entire error, not paraphrase it.

Wonder if it has to do with using math.h instead of the C++ cmath. I doubt it, but cmath is the correct header.

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

I think I can identify where the problem is, I just have no idea how to go about fixing it or even trying something different.

Care to share where you think the problem is, or is it a secret?

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

I apologize for this. I've honestly been trying to explain where I'm at and what I'm having trouble with and providing my code for what I've done.

From your post, I'll update my issue to clarify.

I know it is inputting. I think that somewhere the value after the degree is missing (look at the example I supplied two posts up) and from there, the coefficients are being inputted improperly. I believe the area of concern is the for(int i=n+1;i>=0;i--) loop after the in>>n.

And you call this details? These are thoughts and guesses. "I believe" is a guess. "I think that somewhere" is a guess. There is not one detail in this post. Stop trying to explain. Show us.

Why didn't you mention what it is inputting? (contents of all the variables being input). Follow that by what you expected it to input (expected contents of all the variables)

Where is this information?

Did you try outputting each and every value read from the file to see if something is wrong in your loop?

Where did you give us this information?

And are you sure the coeff array is being loaded properly? output it after the loop.

And I don't see where this info is given either.

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

What do you mean by suspicious?

Sorry bear with me. I've been staring at this code for near 20 hours this week in addition to a combined 60 hours of calc 3, statics, and chem 2. It all is blending together...

I know it's not inputting the value correctly, but I'm failing to understand the mistake that it's making. It looks right to me, but I know it's not.

And with this information, what can we say? Doesn't anyone that needs help understand the concept of details?

If you know it's not inputting properly, why didn't you mention that? Why didn't you mention what it is inputting? (contents of all the variables being input). Follow that by what you expected it to input (expected contents of all the variables)

Details are the only thing that helps, not vague descriptions. Save yourself another 4 hours of pain and loss of sleep.

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

Did you try outputting each and every value read from the file to see if something is wrong in your loop? And are you sure the coeff array is being loaded properly? output it after the loop.

The loop looks suspicious to me.