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

On my post, before the fix, quotes 2 & 3 were identical to 1.

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

No thanks. I already did my homework.

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

Then the file doesn't exist where the program is looking for it.

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

Since you didn't post any code, we have no way of knowing what you did wrong. This is a very simple task and how you tried to do it will tell us what to suggest. Otherwise you get suggestions like the one above by rxlim

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

1) In English, there is always a SPACE after punctuation!!!!!!
2) Dividing ints give you ints. 3/4=0 not 0.75. 8/6=1 not 1.5

During the division make sure one of the values is cast to float (float) 8 / 6 Also, nmb? Please reread the Member Rules -- Keep it Clear, first and last points.

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

You gave up? The process is simple. Each year has 365 days. Every year divisible by 4 (Leap Year) has 366. Every month has a set number of days (except month 2 in LY). A simple matter of addition.
1) How many years*365
2) Add in # of leap years
3) Get number of days from birthday to end of year 1 and subtract
4) Get number of days from beginning of this year to today and add

For 1&2 a simple FOR loop with an IF for leap year
For 3 and 4 two more FOR loops

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

Also although it is generally best to avoid OS specificity and keep C++ platform independant, sometimes it is more powerful to just use the system. (for example the horrible [in my opinion] language of VB is highly OS dependant on windows, yet it is an extremely powerful language that allows you to move windows through each other, and do hardware specific tasks.

Excuse me? VB isn't "highly OS dependant on windows," is was written completely dependent on Windows. Can you imagine having to write all the code necessary to create a form or a button from scratch so VB can be OS independent? Let alone the interrupt structure necessary to run the components! Very bad illustration.


@determine: See this

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

But then im gonna lose the the sizes it might mean that larger disk can be placed on the smaller. With that logic i can't know which disk is larger all i know is it has a disk on peg. I must be stupid i just don't see it.

No, you're not stupid. The problem as you understand it is.
You have 3 cans in front of you. None have labels. Hand me the creamed corn.
This is the definition of the problem as you've laid it out.

Reread the problem again. Where in the problem does it say arrays cannot be used? You must keep track of what specific disks are on a peg. Without that information you cannot proceed as you have discovered. So each peg needs to be an array.

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

The change doesn't seem to be working correctly.

QUOTING: Now, when you are using the quote tags that show/hide the quote, the first line of the quote always shows up. This gives you a sneak peek to refresh your memory what the quote is, and which line of the person has been quoted, without the whole drawn out message all over again.


QUOTE=cscgal;1487820:

Now, when you are using the quote tags that show/hide the quote, the first line of the quote always shows up. This gives you a sneak peek to refresh your memory what the quote is, and which line of the person has been quoted, without the whole drawn out message all over again.

QUOTE=cscgal;:

Now, when you are using the quote tags that show/hide the quote, the first line of the quote always shows up. This gives you a sneak peek to refresh your memory what the quote is, and which line of the person has been quoted, without the whole drawn out message all over again.


QUOTE
:

Now, when you are using the quote tags that show/hide the quote, the first line of the quote always shows up. This gives you a sneak peek to refresh your memory what the quote is, and which line of the person has been quoted, without the whole drawn out message all over again.

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

I am trying to make a program that will read in a text file and count the number of words that have a certain length from 1 to 20. So it should count the words that have a length of one, two, etc., and print it out. I have been working on this for some time, and have taken pointers from some people and have destroyed and rebuilded my code several times. Any help on how I can go about programming this, would be appreciated it.

When asking for help, you need to tell us what the problem is. Don't leave it to us to figure it out.

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

This is my computer science project,we were told to make any software we wish to make,so I thought about making a calculator,below is the code,but it doesn't seem to be functioning well,could anyone help and tell me what went wrong(I am using borland cpp 4.5 compiler,this program uses getch() to read the keystrokes)

1) In English, there is always a SPACE after punctuation
2) As for it not functioning well, try unplugging the computer from the wall socket, then the lights won't go out when you run the program

Now I admit I'm guessing on #2 what "doesn't work well" means since you didn't bother to tell us. If I'm wrong, try explaining the problem.

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

Draw the the pattern on paper. Analyze the numbers you need:
1) for each given line number
2) how many leading spaces
3) how many characters
4) how many trailing spaces
Look for a numerical pattern that can be programmed.

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

What fixed it?

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

Read the line using getline() . Find the last SPACE. Everything before is the first/middle name, after is last name.

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

Good answer. I saw shuffle in the STL docs. I'll google it. Thanks for all the help.

Shuffle the deck yourself, don't use STL to do it for you. You won't always have STL so you'll need to know how to do it by hand.

jonsca commented: I always print out the deck on paper, shuffle it by hand, then I key back in the values. +7
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Line 26:
Ouput account, string2, and string3. See what the values are.

Also, are string2 and string3 useful names? What are they for? The answer will give you better variable names for them.

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

Ctrl, Alt, Shift are not 'keys', they are modifiers to keys. C is a key, value is 67. Ctrl-C is also a key, value 3.

Look on Google for information about Sendkeys

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

Of course, iwould not modify it. But to give suggestion i would need to the code.

e.g. whether OP has use fprintf or fwrite...........depending on it I would suggest fsanf or fread

Stop responding to posts just to respond. I did not quote you, therefore I was not talking to you.

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

According to language, the code is fine.

Read the C standard. there is no new nor delete command available. Period.

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

Then please guide me how to use grphics in visual studio 6.0

You cannot us graphics.h in VC++6. Period. End of discussion.

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

You never put a value into d therefore if ( d < 1 ) is comparing junk with 1.

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

My point on the comments refers to commenting something like this

char character = getchar(); //get a character from stdin

getchar() is a function from the standard library. Its well documented, so I consider commenting its functionality redundant. That said, if your Prof wants comments then give him/her comments.

That may have been your point, but you included

/* Function prototypes */
void process(char input);
void update(char words[][51], int position);
char * toString(char character);

/* the global variables */
char words[100][51];	//the array of the words inside the text
int lastWordPos = 0;	//position of the last word in array words

char tempWord[51] = "";	//temporary array for storing a word
char tempDigit[51] = "";//temporary array for storing a number
	
while(character != '0')	//as long as the character from stdin is not 0, keep looping
strcpy(words[lastWordPos], tempWord);	//add the word to the word list
strcpy(tempWord, "");			//reset tempWord, so that it can be used again at the next loops, if needed
lastWordPos++;				//increment the position of the word list

in your remark. If you didn't mean these, you should have been more explicit. As a veteran programmer, I understood your remark as "don't use comments". How will noobs interpret it?

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

the code is fine and will work........do you want help with the code

The code is NOT fine. It is C++ code, not C. new and delete are C++ commands, not C, therefore, not fine!

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

why don't you share your code, so that i can modify it to give required result.

Yes, the Original Poster (OP) should share his code, but you do not modify it to get it to work. We do not approve of cheating. You can give suggestions on how to fix the code, but it's the OP's job to modify it to give the required result.

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

Find a copy and put it in the include directory.

But if you expect it to work, the real answer is you can't. VC++6 has no graphics functionality that works with graphics.h

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

If you go to the casino, you will never see the dealer 'pick a random card from the deck' (your technique), they 'randomize the deck' (shuffle) and deal top to bottom (use an index).

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

Write some code. Then we help fix.

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

Try running the program from the command line and add your parameters there. See what happens.

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

Also, why all the comments its really distracting.

Because good programmers comment their code so others can follow it.

sorry its an assignment from my university so I have to write all that comments. I hate it too so please bear with me :/

Don't apologize. Keep it up. Comments are critical if you want to make programming a profession.

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

Also, since this is the C forum, using C++ commands to do the work will just confuse and frustrate anyone trying your suggestions.

A for effort, F for execution.

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

You can certainly mark the thread solved (that's a good thing -- thanks).
On the other hand, you could make your program work much better.

What you are doing is getting a random value between 0 and at least 32767. and you are looking for 65-90. Basically that means out of 1260 (32767/26) calls to the random function you will get a letter. To get your 10 letters, you'll have to get 12600 random values on average.

You can cut that down to getting 10 numbers with a little thought -- and searching these forums to find out how to make the random numbers fall between 65 and 90 on the first try.

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

Good. Now try
AA
ABCCBA
ABCDEEDCBA

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

ASCII characters are just numbers. So if you wanted onthe the upper case letters for example, the are 'A' thru 'Z', or 65 thru 90. So
1) limit your random value from 0 to 25 (number of letters)
2) add 'A' or 65 to it.
That will give you all the upper case letters.

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

Start looking into vector ok?
its more flexible and a template. This mean you can extend your code to other data types.

You're kidding, right? What is the Total, Average, and Mean of a list of names? :icon_rolleyes:

richieking commented: Student are can read and try other stuffs before they are thought. This is called education. +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

That would be my take on it.

If you are creating a toy and use Elmers Glue and Scotch Tape (both brand name products but available for "GPL licensing" as it were), your product isn't non-proprietary because of it.

Unless, of course, I'm wrong -- which is certainly possible...:-/

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

Your code is not GPL, only the software you use that is already GPL.

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

How about Aussies and Kiwi's? They speak English (sorta)... :icon_smile:

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

Sorry, you are all wrong. You may have as many mains as you want, provided they are all static (except one, of course). I am not even talking about dll tricks.

Show us you proof -- with working code compilable on any C compiler.

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

No need to be sorry. Instructors like you to do things the hard way.

Just look up strncpy() .

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

Where you got the idea ^ means raised to the power in C is a great question.

Belaying that, look in the math.h header for the function pow()

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

now what do you think is wrong with my new code???

As always, you aren't using CODE Tags.

Also, give a detailed description of what is happening wrong. Each time you post, explain! With CODE TAGS!

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

Look up strncpy() . Wouldn't it be easier to copy the end of the string instead? That way you don't have to copy the beginning and move the end of the original to the beginning.

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

Both answers have the same problem:
1) way too complex for the question asked. This whole program from main() to return can be written in less than 12 lines.
2) Seems to be full working code which means cheating! And we do NOT condone cheating. On these forums we help, we don't do it for them.

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

Here. Stop being so lazy.

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

To change something you need an equal sign.

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

Can anyone fix my problem?

No, that's your job. We can point out where you went wrong...

I'm sure my getDate function algorithm was right, but it still wrong..

... if you'd bother to tell us how you know it's wrong. With the info you gave we don't know what we're looking for.

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

Another problem. You have a pointer for name but you have no storage space. You must declare space to actually store the name.

And read this about gets()

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

Ok here is a little better format.

Much better. You still need more consistency though. Indent the same way throughout the program and watch for really long lines:

const int MAX = 11;
char arrayInput[MAX];
void cStringToUpper (char[]); 
const char SENTINEL[2] = "Q";
char arrayOutput[MAX];

int main()
{
        
    do
    {
        cout << "\n" << "Get Input: ";
        cin >> arrayInput;
        {
            cStringToUpper(arrayInput);             // Call Convert Funtion
            cout << arrayInput;                     // Print Converted Char Array
        }    
    } while (arrayInput != SENTINEL);
    
    cin.ignore(2);
    return 0;
}



void cStringToUpper (char arrayInput[])  
{
    int size=0;
    
    while (arrayInput[size] != '\0')        // while the array does not equal the  null
    {                                       //    term, carry out the convert function
        if (arrayInput[size] >= 97 && arrayInput[size] <= 122)  // Determine if input
        {                                                       //    letters are lower case
            arrayInput[size] = (arrayInput[size])-32;           // Capitalize Lower Case Letters
        }
        else
        {
            arrayInput[size] = arrayInput[size];                // Print all other letters
            size++;                                             //    as they were entered
        }
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Well, i'm really new into programming...

Which is why I'll suggest the 'beginners' way for your 2nd question.

1) vectors -- beginners never learn vectors early on. Use arrays as you've done.
2) new/delete -- generally also beyond the beginner's grasp.

Your solution to use studentName[100] was the correct solution for your level.

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

I have to create a program that asks a person to enter a 2 digit number (10-99) and convert it into words. I've been working on this for days and I still don't see what I'm doing wrong! PLEASE HELP ME!!!

With what? You didn't bother telling us what the problem is.