jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Another forum I visited merged multiple consecutive posts by the same person.

That's a great idea too, but sometimes I've also sent a non-consecutive post saying "see my earlier edit" so the OP would get a notification of it.

It's certainly not a pressing issue, I just wanted to throw it out there for discussion.

Anyway, thanks, Dani, for thinking about bringing back the multiple reply.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
#include <iomanip> // don't put .h on the header file <iomanip>. 
#include <conio.h> // you forgot to include

You are correct about the first one, but this OP is using an older compiler which was out before the header files were established as having no .h

However, conio.h is also a vestige. There's no need to use it, as it's non-portable. There are standard ways to emulate getche() like with a cin.ignore()/cin.get() combination (or flushing the input buffer instead of cin.ignore(), see http://www.daniweb.com/forums/post438070.html#post438070)

jember commented: thank you for the infos.. very cool :) +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Your function definition would look something like: void solution( int a[], int b,int & sum,double & average) -or- double solution(int a[],int b,int & sum) It's probably better to call your function average, have it return a double, and have sum passed in by reference (so the second case above).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

"sum" in your function and sum in main() are in completely different scopes. Functions have their own set of variables and cannot see anything declared in main or another function.

You have a couple of options, either pass both the average and sum variables into your function by pointer or reference (so using a * or a & before the parameter, and having to dereference the * if you do it by pointer), or pass one and return the other.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

how to run my graphics in vc++

The short answer is that you can't. That graphics capability is a library that comes with (older) Borland compilers and cannot be used with other products. There is an older library for other compilers called WinBGIm that's supposed to emulate that Borland library, but I don't think it's in development any longer.

I don't do graphics (beyond GUI) but someone can probably suggest a good graphics library for you (along the lines of SDL or OpenGL).

I'm treading on thin ice as I don't know for sure, but I'm guessing modern Windows versions are intercepting or disregarding the lower level Borland calls from graphics.h.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, you were clear, but I'm trying to nudge you in the right direction.

This was my suggestion:

Scan the string the user enters up until you hit a ':' then convert and repeat.

The case you are looking to avoid is where there is a single digit time (e.g., 9:03:04) because you only have 1 digit, so you need to account for that.

A std::string can be used like an array of characters.

To obtain the integer associated with a number character, subtract '0' from it (e.g., '9' - '0' = 9)

You know the place values of each of those digits so you can get their value and store it as an int.

See if that doesn't get you a bit farther and post back with your attempt.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Test 1 25 %
Test 2 25 %
Test 3 25 %
Final 50 %

adds up to 125%. I think one of your numbers is off.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I tried using scanf, but it wouldn't work (crashed constantly). And the only option I knew was gets();

Well, if you're going to make this a C++ program you can use iostream's methods (cin, etc). Since you're doing this for personal use only, you could switch all of your C-strings to std::strings.

What I'm also getting at is that the functions are not being called because you don't seem to invoke them anywhere (through a cursory glance over your program).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
I also think that Jonsca's an interesting person but his description will come later ..

I just ran across this... I'm touched (okay, I'll delay that until after you write something).

This is what I imagine WaltP's basement to look like: (only it's an operating system built on Bliss with a Lisp-like scripting language on top, and he's ported gcc and Chrome to it)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I do miss the multiple-reply button

Agreed.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think the switch is a good idea. You then simply have to disallow movements to the left when you are on the first column, disallow movements to the up and left when you're in the corner, etc.

That's a fairly involved assignment, so you should test some of the functions separately and then integrate it all together.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No problem. Take a glance back through your textbook on these areas. Don't be afraid to try things out in your programs to test whether you are right.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Okay, you're on the right track. MasterG has edited his post (please don't give the answer away, it doesn't help the OP at all), so see if you can figure out what you need to do with the parameter.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Here is what I made up in a few min, hope it helps, probably easier way to do it.

There is, but I want the OP to try and come up with it first. I'm not sure I understand what you did there, actually. The exercise is trying to get output like this:

square(4,w);
wwww
wwww
wwww
wwww

square(4);
****
****
****
****

at least that's my understanding of it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What would you suggest? I've given you hints on the other problems, so I'll leave the burden on you for this one.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes! :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I don't know if it's possible to add a feature to do this, but it would be nice to know when a post prior to yours in the thread has been edited. I'm more prone to look for it, but when I'm on a thread with someone new to the site I sometimes double post (I know, I know, throw me in the brig) just so the OP will see the added information.

Just an observation/suggestion (since I'm sure you were saying, "hey, how can we load the mail server even more... lol).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Also, delete line 9 (you don't need to make it false if it already is) and change line 5 to an assignment operator (single equals). Review the difference between assignment(=) and comparison(==) it's important.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Can you think of a way (a keyword) to maintain a variable between function calls?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You need to have c==true (really you only need if(c) because c is a boolean variable) Same for b=0, change it back to b==0

Again, rather than have two blocks in your if do the same thing, use || (or) in the one if statement. "If C is true OR b equals 0"

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See if you can see the problem with if(c[B]=[/B]true) If your two if statements are doing the same thing, why not combine them. The OR in my last post was a clue.

A minor thing: you should initialize c to false explicitly when you define it, just to be sure.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Did you compile the code first (the little hammer in the toolbar)?

Otherwise, see this thread to make sure you have the right compiler detected: http://www.dynamicdrive.com/forums/showthread.php?t=25615

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Hint: use a bool variable to keep track of whether you've been upset before. Check whether or not b is zero OR the bool variable is set to true.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
for (i = 0; i < a.length(); i++) 
if ((a[i] >= 'A' && a[i] <= 'Z') || (a[i] >= 'a' && a[i] <= 'z'))

:)

Good catch, I hadn't gotten that far yet, though you should at least give him/her the means to figure out why the logic was wrong.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It gave me pause, but I found this thread http://bytes.com/topic/c/answers/877992-does-object-c-std-string-type-terminates-null-character which would seem to indicate that it just happens to work out that way in some implementations, so I wouldn't count on it working. Use the length member.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Should the function definition have a type?

unsigned is a type, unless I'm misunderstanding your question...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

std::string s don't (EDIT: necessarily) end in '\0' so you have to check and see if you've exceeded the length (which is accessed by the string object's .length() method)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's like the Game of Life or any other of those

***********
***********
***********
***********

Along the border they don't all have the same number of nearest neighbors, so those cases have to be handled separately.

You can do it all in one for loop, but you require more if statements, that's why I thought it would be better organized with

//corners

//row0 

//row N-1

//column0

//column N-1

//the middle (all have 4 nearest neighbors)

There may be a neater way of doing it, but I'm not aware of it, so definitely share your findings Dingbats (sounds like I'm insulting you, LOL).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

This will tell you a little bit about how to create your own >> operator for your clock class http://www.java2s.com/Code/Cpp/Overload/Overloadostreamandistream.htm

Scan the string the user enters up until you hit a ':' then convert and repeat. If permitted you can look into stringstreams, but it's not absolutely necessary.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

As an aside: never use gets. You can input as many characters as you want, regardless of the size of the buffer, potentially knocking a hole into another part of your program.

I had flagged this yesterday to go into C (as the only Cplusplussy thing about it is the using namespace std; .

Can you be more specific about what functions it is skipping?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I don't know if this is a viable idea (so I'm open to criticism), but couldn't you use something like libcurl and "POST" the form data to the URL rather than actually filling the form out on the webpage?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's the best idea for the sake of portability to use a compiler that adheres as closely to the standard as possible. Turbo C/C++ does not (as it arrived prior to the ISO standard, which was established in 1998). Turbo C/C++ can be a 16 bit compiler (I don't remember which version is) which among other things means that you are restricted to a smaller memory model.

Along with Visual C++ (one of the more recent implementations) there is the Gnu Compiler Collection, which includes g++ to compile C++ (or the equivalent mingw port for Windows)

(3000) - ignore just a counter

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I've gotta get going unfortunately, but give it a try and post your problems, someone should be able to give you a hand.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No, it's not the same thing, I mean the main Start menu of Windows.

Separate pieces of code.

//corners by themselves

//first row
  for loop over all of the columns
     check only the sides and bottom
//last row
  for loop over all of the columns
     check only the sides and top

//etc.

So what I said initially about being able to use a for loop to clean up your second listing is only applicable to the middle of the board.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Go to the run menu off of the start menu and type in "cmd" (no quotes).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

We're leapfrogging with our posts hehe. Treat the border of your board as a special case, do the first and last columns, minus the corners, and the first and last rows, minus the corners, the 4 corners, then the middle all at once.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Can you run your program at a DOS prompt instead of within your IDE, that way it shouldn't close at all. You already have a cin statement at the end of main() so I'm not sure why it's closing. Try changing that to a cin.ignore(); cin.get() instead, and if that doesn't work run it from a prompt.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think the error is happening after you're picking the coordinates now that I think about it. If you are at 0,0 for example, when you're doing your checking for '~' you need to only check squares that are up and to the right.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

And how big is the grid in that case?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Right, I meant more like (just as an example)

//generate x and y
//check if they are already taken
cout<<"("<<x<<","<<y<<")"<<endl;
cin.ignore(); //will collect any stray newlines, etc.
cin.get();

This way you get a printout of like

(0,0)
(1,1)
(-13,444) //oops, that's probably it
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The moderators can edit posts/threads only in their given jurisdiction

I didn't remember that, so that's mybad.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I couldn't tell much of anything from the hex dump, but try outputting your coordinates that it's picking to the screen. Put a cin.get() after it so the program will pause before moving on. See if there's anything funky there.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No it's okay, ask away. iSide is a private member variable. As long as you've called iBoard() before you try to pick the spots for random characters, then you'll be all set. Then all you need is rand() % iSide (same for the row and for the column), as that private member variable will be accessible from any method within the class.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you have the size of the array, you know how many rows and columns there are. Limit your random number selection to that range, using the same technique as you used on line 22 (but with different settings that correspond to the range you want).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

how can i randomly spawn characters in a random array?

Pick a row randomly, pick a column randomly, check if something is there already, if so pick another row and another column. I'm sure there are more random ways to do it, but for your assignment that is probably okay.

how can i simplify this code into a much more "finessed" code

See if you can finesse it into a for loop. There's a pattern to the indexes of cSpace. That way you only need the if/else once.

Line 23, you don't need to return anything the information is already within the object. Line 19 and 26, I'd be explicit about the return type as your compiler shouldn't allow implicit int, but since you're using the pre-standard headers it's probably letting you get away with it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

That video has the Visual C++ Express Edition featured, which is a great IDE with a very good debugger. Another option is Code::Blocks which comes with the mingw port of the gcc. That IDE has integrated support for the gnu debugger (gdb).

Turbo C is a dog that's had its day.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

How do I contact one of them?

On the post in question, hit the "Flag Bad Post" button and type them a short message.

(but Ezzaral is a moderator, so you've already talked to one, just sayin')

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You don't need the cin because you are not taking input from the keyboard. Use checkFile.getline(sCusName,30); If you have multiple customers in a file you're going to need a loop to access the one you need.