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

Sound to me as if you either
1) haven't explained what you're trying to do properly (I'm lost)
2) haven't designed the concept well enough to start programming.

Having a timer for SECONDs and another for MINUTEs shows you haven't thought through the task. Based on what I understand, you only need one timer total for the whole project.

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

Move the output outside the loop.

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

Thank You, this code works for me but when I try and sub the lastLine I get from my code in place of your s it does not work? Why is this?

Probably because you tried to add code you don't understand and expect it to work without modification. It's obvious from the code you posted L7Sqr's code is far beyond your level.

JordanHam commented: Rude +0
debasisdas commented: harsh reality +8
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You need to parse the line. Find each (,) and
1) Convert the value to float and store it.
2) Search for a comma
3) If found, skip over it and go back to 1

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

I can certainly try to help in the future. Just make sure the title of your thread is an informative one. I rarely even look at non-info titles like "Help me" or "This isn't working".

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

Thank you so much for your help! The code works now but it only counts the letters, is there nay way to make it count punctuation or digits?

Thank you as well for giving me the link for the code formatting!

Of course. What causes it to count only letters? Fix that.

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

i am genius :P hahaha i found out :P

i should really start using algorithms first and not going straight to compiler :D

Yes you are a genius. Most students have to be told to do the desk work first. Now you see how important it is. Congrats!

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

Yes, exactly. The two posts are related.

Then don't do that. One problem, one thread.

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

Both. Isn't a loop a decision with processes inside the loop?

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

Seems to me that you need to give us a specific code sample and explain what you are asking. Most of what you said is confusing and (I believe) wrong. But because it's confusing I'm not sure.

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

Then find out how big the files is first. Read through the file once so you know how big it is. Then malloc() the buffer and read the file in one read.

Use the read() function to make it faster.

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

Well, yeah, why would you want to realloc() one character at a time? Add 512 bytes at a time.

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

Can u follow up whit a code example

No. We won't write your code for you. As per the Member Rules you were supposed to read, you post code and we help you fix it.

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

An array is any size, say 5000 indexes. If I input a 500 via some function, then my array will have 4500 null spaces hence forth and 500 valid spaces with which to plug numbers into later in the program.

Is such a thing possible?

Of course it is. Just because you specified the total size as 5000 does not mean you need to use all of it. Just use the value entered to limit your size, exactly the same as you would use 5000 to make sure you don't go beyond the array boundaries.

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

Couldn't you mod by 10 then 100 then 1000 and you would get the ones, tens, hundredths, thousandths that way?

No. 128 mod 100 = 28, not 2.

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

After you get the ones digit, divide the number by 10. Now the tens digit is ready for the %.

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

Can't follow the code with the lack of formatting. Please format it and repost.

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

Hence your "Big-O" time goes from about "n-squared", which is about what it is for Nichito's method, to "nlogn" for mine (basically the time it takes to do just the sort).

But you're forgetting the 'time' it takes to do the sort itself. You need to add that to your 'nlogn'+n-squared

I agree with jonsca. Once through one array, once through the second.

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

@Monarchmk u r right, i think we should leave him ...

Not only that, but giving free code away is frowned upon. If they can't post their code, how can they understand your code?

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

The bound that you use on the loop is not correct. "length" is the total number of characters in your memory buffer, it is not necessarily the number of characters that was read with fgets from the file. C-style strings are terminated by a null character. So, you should add the following to your loop condition:

for ( int i = 0; ((i < length) && (mychar[i] != '\0')); i++) {

This will stop the iteration when the null-character '\0' is found.

The loop should be defined as

for ( int i = 0; mychar[i] != '\0'); i++) {

There is no reason at all why length should even be in the test.

Thank you mike for your help, I changed the line in my code but it still came back with the wrong amount of characters again.
The sentence it needs to count within the file is:
hellllloooo i hope this works and i can change and count the letters and characters

but the characters that it comes out with is 116 instead of 83 :s

As Mike pointed out, what's the value of 's' + 1 ?


Might I point out that the information in this post would have given you an answer much sooner since we would have had enough information to analyze the problem.

Also, you need consistent formatting for your code. Please see this. It helps us read your code properly.

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

And why did you post this question in a thread from 3 years ago about a roulette wheel?

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

That completely depends on what the prof wants. He's the best one to ask. My gut feeling is no, just flowchart first, second, and last.

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

yeah i can't get it to work. It's not flushing the stream,

This implies you tried changing your code. But since you didn't post the new code, we can't explain what you did wrong.

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

Is there something about the sticky post at the top of the forum titled Read me: How do I flush the input stream? that you don't understand?

Khoanyneosr commented: Rude and unhelpful +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Create an 'input form' that looks like an InputBox. For every character hit, save it and replace it with '*' in the TextBox of the form.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
start = 10;    // start writing at byte #11
bytewritten = fwrite(&buf[start],1,payload-start,fp);

&buf[start] is the address of the 11th byte

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

Reread Mike's post and answer his questions. He asked the for a reason.

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

Your loop states while (notas[x]>100 && notas[x]<0);} . Can this ever be true? Read your condition very carefully with notas[x] qual to -10, 50, and 110. Write out a truth table to see what happens.

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

You'll have better luck with some explanation, not just posting code and asking us to figure out what it does. Pinpoint as close as you can where the problem seems to be, and what the crash circumstances are.

Basically, what you have here is the same as taking your car to the mechanic, saying "Fix", and walking away.

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

How about it? Same answer.

If things are not working as you wish, you must give details. Post the part of the code that gives you the trouble. Explain why you think it should work and what happens instead.

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

You need to change them to GRAPHICAL in order to change the color.

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

In my system, which is ubuntu, fflush doesnt do anything. Ive tried using fflush(stdin) and it doesnt really flush anything, the characters in stdin are still there. fflush doesnt do anything in my system,its just like another empty line.

That's because the standard states fflush() is only required to work on output streams. It's not 'defined' for input streams, sayeth the standard. That doesn't mean a compiler can't implement fflush(stdin) , you just can't rely on it. And because of that, you shouldn't use it even if it IS defined. When you get used to using it on Windows, then you get to Ubuntu, suddenly nothing works.

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

On top of that, why must there be a rule written down before you won't do something? If multiple people say "don't do it", just don't do it. There is no specific law in my country that say's "when in a crowded movie theater, don't yell FIRE!" But if you do it, you will get arrested anyway.

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

ah ok so i add the word by character with a loop,

i thought i was adding somehow the word as string like cin>>stringA;
and i was changing after.
ok thanks a lot.

Not a clue what you're talking about here.

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

Thank you fbody but i still can't see a rule resembling this restriction.It is addressed to those who post vague questions and ask for code without providing evidence of trying.Well this didn't happen in my posts but at the time when i first started posting .. i admit i didn't read the rules right away but now i was actually trying to abide them.What?Oh .. and where did you see Waltp.. frowns on stackoverflow.com where everybody is posting relevant pieces of code to actually help each other and not vague phrases lile "do this .. do that .. erm .. no no no try that instead".From your private message i understand this is your forum and your site i can play by your own rules which stem from your state of being .. (not being written anywhere) or "provide my great knowledge elsewhere".Is that really the politics on daniweb?Cause if so .. i will just delete my account (not sure if i'm allowed though)

Ahh, so now we're down to personal attacks, even though I've down-repped you once and others have been down-repping you since you started.

Read cscgal's statement again "please don't expect quick solutions to your homework." Read between the lines. Use the logic necessary in programming for more than programming. What's that statement say from the helping side of the post? Isn't posting full working code a quick solution? N'est-ce pas?

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

Posting code isn't the problem. It's the situation and type of code posted.

Read this.

Yes, as cscgal says:

Though we are all here to help, please don't expect quick solutions to your homework. We'll help you get started, exchange algorithm ideas, how-to's, etc. but only if you show that you're willing to put in effort as well.

So, to the question "Can anyone tell me what am i missing?", it's listening to long-time members, moderators, etc. and doing your own thing against their recommendations.

And consider yourself lucky. This thread is in direct violation of the Keep it Organized rule "Do read the forum description to ensure it is is relevant for your posting". This post does not belong in the C++ forum. So, if you really want to complain about rules...

And speaking of rules, the rules of English require a SPACE or two after punctuation. Don't know about your native language, but here the rule is "Do post in full-sentence English" (Keep it Clear). I think we've let that slide for over 200 posts, haven't we?

All we're asking is if someone suggests that you stop doing something, then stop.

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

StringValue[0] is the 1st character in the string.
StringValue[2] is the 3rd character in the string.
and so on...

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

1) It isn't, really. Reference param passes the address into the function rather than the value.

2) Yes

3) new doesn't store anything. It defines space and puts the address of that space in the variable specified.
Consider variables as boxes you store stuff in. Each box can hold a specific type (books, school papers, clothes) and amount of data. Well, new is like yelling to Mom "Hey, I need another box!" She gives you one after making you say Please and you can store your action figures in it. It just gives you more storage space you didn't have when you started.

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

i have a question lets say that i have a string "hello" how i can witch between letters? to e or l or h?

i suppose it can happen like array using brackets but how?

What? Please be clear.

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

It will happen automatically.

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

I'm sorry I thought you would use my code to see the error for yourself first hand.

Why?
it's so much faster for you to tell us than for us to create a project, add your code, and compile. And I for one have many other posts to look at.

Error is that Convert(int) already has a body.
I think it's because I'm trying to give it 2 commands (for finding hours and finding remainder).

Yes. What does Convert() do? Why not give the functions names that makes sense? Neither Convert() function really converts.

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

Error #1- You didn't use CODE Tags
Error #2- You didn't bother to tell us what the error you're talking about is. This isn't the Psychic Homework Help Desk.

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

The Amish -- no phones, no modern conveniences.... You know, the buggy drivers.

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

To avoid this problem in the future, compile often.
Write the basic code framework first (includes, main(), return) and compile.
Write a class and compile. Make sure it compiles clean.
Write the next class and compile.
Write a function and compile.
Keep adding and compiling, fixing any errors immediately as you go.

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

Problem #1: switch(inst[50]) -- this command only checks the value at inst[50], which is the byte one past the end of the array inst. What are you trying to test here?

Problem #2: case 1: -- You entered characters, not integers, and this case is an integer value.

Is there anyway that in the first switch statement i could use both Char values and int values?

No. Since you don't have any integers, it doesn't matter.

if i wanted the user to enter either 1 or a 2 and they enter a z or an f or something, i would like it to prompt them again... but i can't figure it out...

You've already got it set up properly in the default case.

Your understanding of integer vs character needs to be fixed. If you are reading a character string ising cin.getline(inst, 50); , and you press the keys 2 5 1 enter, you did not enter the integer 251, you entered the characters '2', '5', and '1'.

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

Or add another value called HighCard. For a pair, set HighCard to the value of the pair (4 for Fours, 11 for Jacks).

This would be helpful for Pairs, Trips, Straights, etc.

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

Each character has a numeric value
'A' = 65
'B' = 66
'0' = 48
'1' = 49
and so on.

Subtracting '0' subtracts 48, so '2' - '0' = 2 , equivalent to 50 - 48 = 2 Now look at the code you posted. Does that shed any light on the subject?

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

Okay, so headers cannot be used. May I know any other way to do it?

Please ask a full question. It's too hard to piece together what you want to know by picking and choosing from your last post. Be specific.

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

Hello

I need some help as to the limitations or flexibility of header files. I have written a code that updates a base folder when it is compared to its newer version. I have hit on a roadblock though.

If a new file is added to the folder, the program throws up an error.

I'm sorry, but what is it about new people that think that just telling us "an error happened" is useful? With 1000 possible errors, you think we're psychic? :icon_rolleyes: Next time tell your mechanic "my car makes a noise" and see if he fixes it. <<annoyed>>

I plan to create a header file, which I can include into the program, which contains a function that will compare the file names in both files and in case a file doesn't exist in folder1 but is present in folder2, it copies the file to folder1.

I plan on using the replace and rename commands again, but am unsure of using them in a .h file. Is it okay to define functions in the header file?

No it's not. the only thing that goes into header files are declarations -- things that don't use any space at all.

Function prototypes, constants, defines, externs are OK. Variables, arrays, and functions are not.

By putting definitions in the header, if you use the header in 2 modules, you will have 2 definitions of the same item -- a definite no-no.