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

speel chesker workee fien, und allways haas forr mee!
Never had to set a thing, and rounded corners are off.

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

BGI graphics was designed for earlier Borland compilers and won't work with 5.0+. So you have to rewrite the output portions of the program to remove the screen manipulation. Or you can find a graphics package you like and rewrite the output sections.

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

StoreID[41] is a single int. Change the lines that use the function:
4: int GetID( int students, int StoreID[], int i);
15: GetID(students,StoreID,i);
22: int GetID( int students,int StoreID[], int i)

Also, try displaying the the array when you return to see if it's loaded properly. All you displayed is the single value of the ID after the last one entered...

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

Laugh it up, fur ball! :icon_mrgreen:

WolfPack commented: Yep. The Spread is off. Please Please before Dani finds out about this and fixes the bug. m(__)m +6
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

It wasn't solved when I posted. And you seemed to be getting whiny about your games... It just got tiresome. Over and done with. Friends again? (even if you did give me a red mark :icon_confused:)

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

Personally, I sometimes use while(1) or similar for things like menus, where choosing a menu option would cause the program to do something and then return to the menu. Then, if you want to exit the program, just return 0 to end the program:

int main()
{
   int bob;
   while(1)
   {
      cout << "Enter a number to display, or -1 to exit: ";
      cin >> bob;
      if(bob == -1) { return 0; }
      cout << bob << endl;
    }
}

This is generally not recommended, although it does work. The reason is you are burying the exit from the function/program in the middle of your code. This could be a maintenance nightmare for the team that inherits your program (or for you in 2 months :icon_wink:) It would be best to break out of the loop and return at the bottom of the function.

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

Christina -- stop it!

No one is saying we should completely get rid of games. Just move them out of the Geek Lounge to a Game Lounge. That way us geeks can continue our geeky discussions because that's where we go for it! Telling us to not visit so you can play games is not productive, especially when a solution that works has been offered.

And here is where Dani gets her info on what we like and dislike, not from PMs. You think she wants a lot of whiney geeks PMing her? Not on your life!

As for "There are word games, yes, but there are also other intellectual discussions dealing with politics and religion", look at the facts:
Of the 25 posts on the first page, 13 are games. That's over 50%. And as far as I can tell, 3 discussions. Not very good odds. Used to be 3 games.

christina>you commented: what is wrong with u? don't go crazy! -1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

in this question i dont know the causes of the error : the topic is doubly link list which is soted.. the type of the data is a structure.. i did it but can someone check it out for me???

Neither do we, since we don't have a clue what type of error you're talking about. Seems the DaniWeb Psychic Plugin isn't working at the moment.

Please be
1) less vague
2) less code (341 lines to find an unknown error as a little much to ask)
3) more proactive -- read the announcements at the top of the forum
4) more helpful -- format your code so it can be understood

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

You should avoid using !eof it has problems.

Why?!? You should explain what those problems are. See this (.eof() is the same as feof())

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

After you read a word, check each character and if you see a non-letter or number, it must be punctuation. Do what you need to do with it.

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

why don't u better use a CHAR as a centinel? like this:

char ans;
   do{
      (program)
      printf("Do you wish to enter another temperature?");
      scanf("%c",&ans);
      }while ((ans=='y')||(ans=='Y'));

Hopefully, because of this :icon_wink:

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

strings or c-strings? You need to give us more information on how your program currently is written.

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

So why can't these 40000 people be deleted? Or is the number helpful in marketing the site?

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

Why not have an answer string which you load with '_'s and just output that string. As correct guesses are made, replace each '_' with the letter.

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

How about just running the code from the command line?

Most people have no idea what the command line is, unfortunately. And doesn't it defeat the purpose of using an IDE that allows editing, compiling and running the program to pop out of it after editing and compiling just to run the program?

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

That's okay, I got it. I had to use an if/else statement within the other if/else-if statements. :p

Actually, no you didn't if you did not change your IF statements. else if (choice == 'C' || 'c') is not a proper comparison. What this does is OR the 'C' and 'c' together giving 'c', then test if choice is == to 'c'.

To test an OR condition you need to test each case separately: else if ((choice == 'C') || (choice == 'c')) Also, else if (choice > 'C' || numberofHoursUsed >744) is not a good comparison either. What if someone types in '1' as a choice? It could happen. When you get to this else, you know the choice entered is not A, B, nor C. And since the input for numberofHoursUsed is only in the previous else conditions, you never have a valid numberofHoursUsed at this point. And where you actually do enter it, 800 is a valid value!

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

Because the government added tax to the calculation.... :p

Actually, because you never calculated overchargeTime. You mistyped the equation for that calculation.

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

srting FirstName[10];

Do you mean to make
1) an array of 10 strings
2) a string to hold 10 characters?

If 1, you reference the length with stringname[index].length() If 2, you create the string with char stringname[10] then reference the length with strlen(stringname)

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

any hint on each question how to begin with... i have exams tomorrow ><

Better late than never, eh? ;)

Hints? OK:

Q1)Write a program that read two integer and determined and prints if the first is a multiple of the second? {Hint: Use the modulus operator.} ?

Read about the % operator.

Q2)(Hypotenuse) Define a function hypotenuse that calculates the length of the hypotenuse of the a right triangle when the other two sides are given. Use this function in a program to determine the length of the hypotenuse for each of the triangles shown below. The function should take two double arguments and return the hypotenuse as a double.

Triangle Side 1 Side 2
1 3.0 4.0
2 5.0 12.0
3 8.0 15.0

Check out the equation of a hypotenuse, and look at the sqrt() function in the header cmath

Q3) Write a function multiple that determines for a pair of integers whether the second is a multiple of the first. The function should take two integers and return true if the second is a multiple of the first, false otherwise. Use this function in a program that inputs a series of pairs of integers.

See Q1

Q4) Write a program that inputs a series of integers and passes them one at a time to function even, which uses the modulus operator to determine whether an integer is even. The function should take an integer and return argument true if the …

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

Oops.... so it is. Thanks Sannie :D

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

now if you want to give a range you can do it by this syntax

(minimum+rand())%maximum;
for example if you want to generate the numbers between 1 and 10,000 simply do it this way

(1+rand())%10000;

Not quite. it's minimum + (rand() % maximum);

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

Open the header file in an editor and take a look?

Or cheat and look here :)

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

u ... u ... u ... u ...

:confused:
Read this please.

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

I see Ancient Dragon has typed faster than I and with a more precise version of what to do. As a learning experience here's a sampling of ideas I have about your code:

1) use int main(), not void main()

Yes, see this

3) when using statements requiring braces format your code such that you line up the braces so it's easier to make sure you have matching numbers of opening and closing braces. You appear to have 1 too many closing curly brace in the code you posted.

Yes, see this

4) if you're going to use scanf(), and for beginners it's okay, though it's not the best way to obtain input, then read in an entire string with use of %s, words instead of %c, &words.

No, see this and this. Recommending scanf("%s"...) is the same as recommending gets()

All of the above are issues commonly seen in code written by beginners, and more frequently than I like to think, in code I write still.

Hmmmm.... :D

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

See this about system("pause"); system("cls"); is conceptually similar.

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

since we are using std::string, why not

#include <iostream>
#include <string>
using namespace std;
int main()
{
  string str ;  cin >> str ; 
  const string vowels = "aeiouAEIOU" ;
  int n_vowels = 0 ;
  for( string::size_type pos = str.find_first_of(vowels) ; pos != string::npos ;
        pos = str.find_first_of(vowels,pos+1) )  ++n_vowels ;
  cout << "vowels: " << n_vowels  << "\nconsonants: " 
          << str.size()-n_vowels    << '\n' ;
  return 0 ;
}

Probably because it's beyond his current knowledge... ;) That's for someone far above his level of experience.

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

As for part 1, I believe the instructions are referring to c-strings...how much do you know about c-strings?

I don't think so. Although, I don't know what the instructions mean, either.

Can you give us an example of the operation?

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

Of course not....

void defaultParam ( int u , int v = 5 , double z = 3.2 )
{
    int a ;
    u = u + static_cast<int>( 2 * v + z ) ;
    a = u + v * z ;
    cout << "a = " << a << endl ;
}

defaultParam(6) ;

What's u, v, and z?

Now what's u + (( 2 * v ) + z ) ? Replace u with this value -- as an integer

Now what's u + (v * z) , also as an integer after calculating.

Are the lack of parentheses in the original equations throwing you? If so, prime reasong to paranthesize everything!

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

Your desk-check of the first call (6) is wrong.

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

Here's a simply way to do it with a while loop.

And how does that poorly formatted program help with

I'm trying to write a program in C using nested loops which ...

:rolleyes:

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

First, format your code properly.

What does your book/instructor say about a FOR loop and/or statement? What's it do? What does it execute?

What does the program you wrote do? What does it not do?

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

What's with that column structure?

A combination of real code and psuedo code to play a location:

int board[7][7];

clear board -- set all locations to 0.  SPACE can be used.

accept location to move: row,col  // must be 0-6, check for error
if (board[row][col] != 0)
{
    display "location already played";
}
else
{
    board[row][col] = player;    // player is 1 or 2 for example.
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

By reading the header of the picture file. Loot at http://www.wotsit.org/

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

Hello,

I wanna know if there is any way to make a window transparent using Win32 API


Thanks in advance,


Jan

I see lots of possible answers putting the important parts of your question in google...

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

There are other problems..
"Generate 100x4 unique arrays" even rand() won't exactly be rand() if you have a fast enough machine..

What's this supposed to mean? Random has nothing to do with the speed of your machine...

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

Hey All i am making a connect four game. I have done most of the code but need help in some bits

1) Which is how to code to see if there a win from vertical, horizontal or diagonal. - The Grid is 7 by 7. - I no idea how to code this and if i need in a function on its own or in the main game loop, also do i need make one for both p1 and p2? or will one just do??

As vishesh suggests, a 7x7 array would work great. You can define the board to be int board[7][7]; .
Then for every move (say board[2][3] for 3rd row, 4th col) you look at all the locations that could make up a win.

The more functions you create, the better (within reason)

2) After someone wins I want be able to score the result of both p1 and p2 (win lost or a draw) into a notepad file. I also want make a function to get that notepad to bubble sort all the top 20 players and show them in ranking order. Also is there a way of getting the notepad file not to allow ppl to edit the scores without playing the game??

Open the score file in append mode. Output the new score, close the file. This will give you a list of all the games which you can process when you output the scores.

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

I tried spacing stuff out and lining things up ...

Does look better. Read this tutorial for more information.

... but really didn't add many brackets because they've been a sore spot with me.

That's like saying "I want to be a writer, but punctuation confuses me so I won't use much." Simply put brackets around every statement that could be a compound statement. ( if , for , while , etc.)

Any suggestions you (or anyone else) have further regarding the formatting are welcome and appreciated. Thanks again everyone.

Look at good code. Check out the code from poster's here that have a high post count. See what they do and compare it to the tutorial above.

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

Thanks a lot. It's reading the file just fine now but I noticed another problem after running through a couple generations. I neglected to include a command to populate a cell with three neighbors. No kids means everyone just slowly dies out. Here's the relevant code (let me know if you need more):

I don't think I understand. What does this code do?

if (neighborcount == 2)             // 2 neighbors 
    tempWorld[i][j] = World[i][j];  // stays alive.
      else if (neighborcount == 3)        
    tempWorld[i][j] = true;         // 3 neighbors:
                                        // stays alive

      else tempWorld[i][j] = false;      // 1 and 4+ neighbors:

Doesn't it test for 3 neighbors?

And please format your code better -- it's a little hard to follow. You need more {}'s and proper indentation to make it easier to read.

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

>my problem is, that i have been trying to use a counter to display the average and im stumped
The problem is that you need to store the data in some sort of array -- preferably a vector, and then you can calculate the average.

Why? Go simple.
In this loop:

while (inFile) //End-ofFile Controlled Loop
{
    outFile << "\t" << ref << "\t" << mydate << "\t" << Celsius(ctemp)
            << "°F" << endl << endl; // Write Record
    inFile >> ref >> mydate >> ctemp; // Read File
}

Simply add ctemp to a total counter and add 1 to a 'lines read' counter before your output. Then when you exit the loop, calculate total/lines. No need to store all the data unless you need it later in the program.

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

Yes

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

you need kbhit()

That's nice, do you think system("cls") is standard and cross platform compatible?

This was hilarious!!! Suggesting a non-standard function then pointing out something that's not standard! :) Decide which side of the standard you sit on and stay there, don't vacillate.

Also, system() is a standard library function. It's the parameter "cls" that's system dependent.

You don't have memory leaks. You have a runaway program that will take whatever resources it wants.

Fix the kbhit() problem, and that will correct most of it. (if you knew to use kbhit() you certainly can find out how to use it)

Fix your input then we'll get the timer thing working...

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

What kind of trouble? Unless you show us what you've tried, we can't help. Be sure to read this and this

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

I would suspect you don't have space allocated for the array. How big is the array you defined? Or have you defined just a pointer?

Can't tell from what you've posted.

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

Boy is this thread full of BS :D

1) cstdio is not deprecated. It is the C header for C functions fully allowable in C++. You don't deprecate a language... C is a language, not an old set of functions for C++. If you can offer a link stating otherwise, please do so.

2) It is better to use C++ I/O functions in C++. But C I/O functions are allowed -- although it is best not to mix the two, because they do work differently. If you use getchar(), use C input functions throughout the code.

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

The code is above!

You mean after all these suggestions you haven't made any changes to the code you posted? No wonder it's not working. :rolleyes:

John A commented: What the heck, you deserve some more rep after all your hard work... --joeprogrammer +8
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

The corrections print out each word of the sentence entered on a seperate line. One word per line. I am trying to get the program to remove multiple spaces entered between words but print out the new sentence with only 1 space per word (all on the same line). I still think there may be a problem with my loop.

Probably. But I don't think anyone here has perfected psychic debugging yet. Without knowing what the code looks like, what can we say?

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

First thing is for(int x = 0; x < (strlen(a)+1); x++){ will blow your array boundaries. You definitely don't need the +1 -- and probably want something like x < (strlen(a)-strlen(b)) instead.

Then you need a loop within a loop:
Search through a looking for 1st character in b.
When you find one, start another loop that tests the next values in a to see if they are the same as the rest of b

3rd, give your variables better name. Learn to make the names have meaning -- it will help as time goes on.

Last, use CODE tags.

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

i am a newbie in C++ file processing...
Any1 can guide me to search for an item(lastname) in the example below?
what is seekg or seekp... how to use it?

Not a clue what you are asking. Maybe you need to explain the problem. Remember, we're new to it so details will help.

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

Okay, but it doesn't seems to have any easy-to-use compiler.
Is there any compiler that is just compile *.c format file instead of so many functions that makes itself more complicated than it's already is?
Thanks.;)

I don't understand this question at all. What compilers don't compile *.c format files? What functions don't you want?

If you don't want to use functions, then don't. No one ever said you have to use the ones that come with the compiler, but I for one would rather use their I/O functions that write my own...

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

@ WALP,

Thx for ur suggestion.....but the code that I typed seems to be already formatted above in a better way...

It does? Try actually reading the link I posted and look at your 'readable' code...

dont no who did that but is that readable now??

SOS did it, and no it's not readable.