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

try this code.

But he wants it for the computer, not the iPhone... :D

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

And you don't need to call a function to exit, just return 0;

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

i should have posted there error messages, but there were 50 somthing...i did not see the two typo's of namespace and <string>. ty

So just post the first 5 or so. Usually the first one you fix gets rid of a lot of the errors.

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

Reformatting slightly, is this what you really want?

rectangleType::rectangleType(double l, double w ) :lineType(l)
{
    width=w;
}//end lineType constructor
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Please forgive me...I'm still new posting anything in these forums but...code tags? I'm sorry. That probably seems stupid of me to not know what that means. Like I said, I'm new to posting in these forums and as far as programming goes, I'm still pretty new to that too. I'm only in my second computer science class right now. Thanks.

CODE TAGS
read any of the requested information posted all over this site about 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

Subtract 24.

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

Set grade total to 0
Start a loop.
For each input, add the appropriate value to grade total
Count each input.

You can figure out how/when to end the loop and calculate the rest of the grade

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

i am having a few errors compiling a code in visual C++ with my jumble word code, can anyone help?

Yes we can, if you give us an idea what's wrong. We can't see your screen with the errors.

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

>>when I tried to run it, it suddenly closed

That's because there is nothing at the end of main() to prevent that behavior. If you want it to stay open so that you can see it, then add getche(); at the end of main(). The program will then stop until you hit a key.

Dragonmeister!?!?! getche() ?!?!? getchar() please. It's at least standard...

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

OK, but you need to read the Forum Rules and the Sticky Posts first.

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

None that I can be bothered to mention any more, thanks to your vague requirements.

Its not vague...
Can someone else please help....

If Salem can't understand what you need, believe us, your description is very vague... You can't prove it isn't by simply saying so.

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

So far you've refused the help. I will now be exceptionally clear and repeat: READ THIS!!!! Especially the section titles Describe your problem clearly and fully!

Did you post code? Did you explain what the problem was? Did you give us any information to help you? No. You only said "send me code" and that is asking us to write it for you.

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

Start month at 1 (January)
If your day > #days-in-January
Subtract #days-in-January from your day, add one to month.
If your day > #days-in-February
Subtract #days-in-February from your day, add one to month.
etc.
The first time day <= #days-in-'month', you have your answer.

Set up a loop and an array to do this.

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

i need help in making c++ code for tic tac toe on 7x7 board by using mini max and alpha beta where 4 in a row ,column,and diagonal are winning state , if some 1 can share code it will be quite help full 4 me

We don't write code for people. We help them fix the code they write.

i make a code that was working properly on human vs human but not on human to computer

Then you wrote it wrong.

i already make a code that was working properly on 3x3 board but not on 7x7 on 7x7 it work properly as human vs human but not on computer vs human on this it stuck up ....

And it's going to remain stuck up until you start reading the Forum Rules and the important Sticky Posts at the top of the forum.

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

OK! I understand that I can't read a file exactly as I think. So I'm asking again but different : How can I do this process :
the file is:
11111111110000000000
the compressed file is 10111010. <----5x1 5x0

How I can I do that ? It should be a way to do that. If it not possible on C, I know little bit Java maybe I can do it on Java ?!

Is the file a bunch of text characters 1 and 0? Or is it in fact a bunch of bytes 0xFF 0xA0 0x00?

We don't know what "the file is" really describes.

and how do you know 10111010 is 5x1 5x0 and not 0Bx1 1x0 or 2x1 3x0 1x0?

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

This code you are asked to input a number and it will tell u wheter or not the input you entered is in the array or not
i am having issues with this code and its giving me some errors,
if anyone wants to help me out it will be greatly appreciated!

Stop posting your questions as Code Snippets.
When you ask a question, give details! "Having issues" does not give us any information. Explain your problems and give us an idea where the problem is.

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

Maybe you should be clearer... :icon_wink:

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

Do not resurrect an old thread to ask a question. You should only post help to an existing thread.

Now go start your own thread and reword your question giving us all the detail necessary for understanding exactly what you want.

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

Sure. Read this.

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

1) Format your code so we can easily follow it
2) Never paraphrase an error -- give it to us exactly!
3) Out of 145 lines, which one has the error?
4) main() is an int function -- see this
5) Why are you using conio.h. There is nothing in that header you really need. And it's not Standard C.

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

Learn both. They both have their uses and one can do things better than the other in many cases. It also gives you the ability to choose the best language for the job.

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

And of course, the not-so-smart programmers are cheaper... :icon_wink:

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

et. Like in the Beverly Hillbillies -- I et possum stew.

Oh, you mean Detroit! De - twa.

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

this is my daughters homework she asked me to help and now im stuck she has worked it out and is making me look stupid need to get my selfrespect back even if i have to cheat(i used my brain and im asking you) the code is as follows but i cannot get it to work

IMO, you'll get more respect from her (which is more important than your own) by admitting she's better and having her teach you. It'll do wonders for her self esteem, which is sadly lacking in people now-a-days. And you'll feel better knowing you gave her a great ego boost.

By the way, no one can make you feel stupid. Only you can do that.

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

This is not a code snippet. This is a help question. Read the Rules before posting.

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

I want to read a file exactly how it is on my hdd . like this: 101010111111000101010 . I have to create a new file after reading by changing some 1 and 0s . I have to change them to compress the file.. For example (very simple example) the file is :
11111111110000000000
the compressed file is :
solving :5x1 5x0

the file is 10111010.
I have a big plan for that! But first off all I need to know how to read and write a file as binary...

WaltP you can't do that as opening the file as binary. I don't know why :(

The only way to read a file as binary is to open the file in binary mode. If it doesn't work, you can't read the file. Period.

You are under the misconception that reading in binary reads a bit at a time. Not true. It read the same as anything else -- bytes from the file are moved into bytes ( char s) into your read buffer. And that is exactly how it is on the disk -- a series of bytes.

After reading, it's then your job to look at the values as bits.

Add to that, there is no bit type in C. The lowest you can deal with is a byte.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
int getAvg(school student, total)
{
    ...
}

What type of variable is student ?
What type of variable is total ?

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

Open the file as binary.

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

For UP, if number is MIN, set number to MAX.
For DOWN, if number is MAX, set number to MIN.

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

If you are having trouble with step 2, you should not have any code for step 3 and beyond.

Edit out all the stuff you cannot test without step 2 being finished.
Then perfect step 2.
Add step 3 and make sure it works.
Then start adding step 4, a piece at a time.

The hardest way to write any program is to write the whole thing then start testing. You get lost fast.

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

Then there is Detroit.

Does there have to be? I grew up there, so I'm trying to forget... :scared:

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

For example, your wrapper could keep track of all the memory allocated and deallocated. This would help you make sure you aren't attempting to deallocate twice, or not deallocating at all.

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

Tell us how you would add two matrices on paper.

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

So declare total . What type of variable is it?

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

In AddNewElmnt() you never checked the list to see if the character entered is already there. Check before adding.

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

Because in the first case, the pointer p is pointing nowhere. You defined the pointer, but never pointed it to space for the data.

In the second, you allocated data space, and the address was placed into the pointer. But the only reason it didn't segfault is luck. The space malloc 'd obviously included some fudge room. It could be that the malloc actually allocates a buffer in chunks by K. Another malloc would take more from that chunk without having to access the heap.

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

Yes. But the '\0' in 7 is the end of the string so the last few characters are essentially invisible.

and you do not want to rely on someone typing less than 12 characters.

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

The problem here is that although I manage to rename the file name from "unsaved.txt" to whatever the user enters, the global char* variable (fileName) won't change and remain "unsaved.txt" so the next time I try to write something new into this file it will still create a new "unsaved.txt".

You cannot change the contents of a constant string, which I assume is your problem. If you have: char *fname = "unsaved.txt"; it's a string constant and cannot be modified.

On the other hand, if you have char fname[] = "unsaved.txt"; you can change the name. But if you change it to "theRealFileName.txt" you have another problem. You just moved 20 characters into a string defined as 12 characters so you overwrote unknown memory -- a very bad thing.

To fix that, define the string as char fname[100] = "unsaved.txt"; and you'll have 99 characters to play with.

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

It means the people that designed the compiler assigned the value E2293 to the error. And unless you miscopied the error, it is ") expected".
So look above whatever line is wrong for a missing )

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

FORMAT!!!! How do you expect us to read that?!?! Use the PREVIEW button and if you don't like what you see, neither will we -- fix it!

If your pumps hold 100 gallons and you ask for more than 100 gallons, the pumps at that station can't handle the requests. Seems to me going to another station with greater pump capacity is the answer...

Unless you didn't explain your task fully.

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

This is NOT a code snippet, this is a help request. Post properly. Look up what a code snippet is if you are unsure.

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

I have connected to the IRC a few times, but no-one is ever on when I do :)

Makes sense. With the 8 or so people that use it, the chances that any one of them are on at the exact time someone enters the IRC is slim at best. And assuming someone waits around for 5 minutes hoping, there are only 287 5 minute slices in the day the others may show up -- a slim margin.

Not a clue how this can be rectified... A bulletin board where someone can post when they will be around might work -- assuming someone can plan that far ahead

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

Allocate a large temporary chunk of memory when recording starts. If you need more space, allocate another temporary chunk -- not one at a time -- to save time. Keep track of your chunks.
When you stop recording, Allocate one more chunk just large enough to hold the entire recording and move the recording into it, deallocate the temporary memory.

This can be more elegant, but it should get you started. Also, look into reallocate commands. They may help, too.

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

What am I doing wrong?

Not reading this and this as requested, and assuming we are psychic.

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

How to create Run as Administrator option of windows OS in c code..

It is required for my software. plz help me.

How to ask questions here -- read this and this.

It is required for this forum.

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

The only way for us to understand your problem is for you to post your code.

I think a better description of the problem would help -- not the code...

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

Yet Another Version of Findind a Prime number:

snipped

i Hope this is the Efficient Version of All.
Any other ways, Plz Welcome.

I hope this is a joke.

Please, do not take this code seriously... :icon_rolleyes:

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

Recommendation---

Start over.
Write the input function. Test it.
Write the display function. Test it.

you can copy the code from the current code to make it faster, but from now on *never* write the entire project without compiling and testing often. Write it in segments.

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

Like gauche, which is not used frequently anywhere, and literature reflects common language more than anything. I challenge you to find in any writings or documents where the word gauche is used in any way that could be described as commonly.

I must bow to your extremely well-read self. I for one don't have time to read all books, magazines and newspapers that [have been/are being] printed in the English-speaking world, so I'm sure I've missed quite a few.

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

Hi all,

I am stuck here after several hours tried.
Here the thing. I have txt file that contain float data (1 column and many row) such like this (4 float data):

0.799
0.851
0.926
1.000

Then i want to read it as array. My code is work until this point.
After read it as array, than the code should copy each data
as much as number enter by user.
The user should enter 4 different number, since there are 4 float data in the read txt file.
For example if user enter number 2,3,1,2 respectively, the code must copy the 0.799 two times, the 0.851 three times, and so on.
Then put in the different txt file.
In this case the contain of new txt file must:
0.799
0.799
0.851
0.851
0.851
0.926
1.000
1.000

My coding failed to do this task, instead copying each of data as accumulation number input by user. So in this case the accumulative value from 2,3,1,2 is 8 (2+3+1+2).
My result so far are:
0.799
0.799
...
0.799 (until 8 row, then)
0.851
0.851
...
0.851 (until 8 row..and so on )

My guess is you're supposed to enter as many numbers as in the file, right? So after you read the file, set up another loop and input the numbers into another array. Now your …

me_roy commented: thanks WaltP finally i did it... +2