Search Results

Showing results 1 to 37 of 37
Search took 0.01 seconds.
Search: Posts Made By: Ptolemy ; Forum: C++ and child forums
Forum: C++ Nov 2nd, 2007
Replies: 2
Views: 1,010
Posted By Ptolemy
>I wanted to create a MMORPG.
That's waaaaaaay beyond you at the moment. Focus on learning C++ as best you can, but don't expect to be able to write an MMORPG anytime soon. You need a lot of...
Forum: C++ Nov 2nd, 2007
Replies: 2
Views: 6,418
Posted By Ptolemy
>I know the theory behind it but i dont seem to be able to put it into code!
Then you don't really know the theory behind it. ;) Not to be rude or anything, but these are all pretty straightforward...
Forum: C++ Nov 1st, 2007
Replies: 13
Views: 5,339
Posted By Ptolemy
>I just wanted to change the first character in the sentence to
>uppercase, what would I change to do that?
Don't call toupper on every character, just on the first one:

void printSentence(char...
Forum: C++ Oct 25th, 2007
Replies: 4
Views: 1,396
Posted By Ptolemy
>Not any more -- C99 has changed that for C language
While C++ has a certain measure of compatibility with C, it's with C89, not C99. In C++, array sizes must be compile-time constants.
Forum: C++ Oct 25th, 2007
Replies: 11
Views: 2,626
Posted By Ptolemy
If you understood the problem well enough to actually write this program, you wouldn't need to ask what language is best. I'll go out on a limb and say you're in over your head at present.
Forum: C++ Oct 25th, 2007
Replies: 4
Views: 1,396
Posted By Ptolemy
>is dynamic memory allocation really necessaryÉ since you already
>know the size of the array which is being passed by the caller
Really? How do you know? If you're talking about the length...
Forum: C++ Oct 25th, 2007
Replies: 40
Solved: c++ scores
Views: 3,190
Posted By Ptolemy
Oh, don't read it as me bashing your solution, it's the same one I'd use. I was just mentioning that little pitfall because I'd noticed it while brainstorming. :)
Forum: C++ Oct 25th, 2007
Replies: 13
Solved: xor linked list
Views: 2,967
Posted By Ptolemy
>but don't know how to use cast. can you help me?
That's something that any C++ book or reference will tell you how to use. It would be "cast" or "type cast" in the index.
Forum: C++ Oct 25th, 2007
Replies: 5
Views: 644
Posted By Ptolemy
>since its not returning anything?
I don't understand. It's clearly returning something because the code that calls the function uses the return value:

kptr = function2( n ) ;

You can't use a...
Forum: C++ Oct 25th, 2007
Replies: 40
Solved: c++ scores
Views: 3,190
Posted By Ptolemy
>Once you have a student answer string you compare each element
>of that string with each element of the correct answer string
But from the sample file it looks like if the last N answers were...
Forum: C++ Oct 25th, 2007
Replies: 13
Solved: xor linked list
Views: 2,967
Posted By Ptolemy
>i found something but it has an error :"xor1001.cpp
>invalid conversion from `void*' to `link*' ".
You're compiling C as C++. C++ doesn't support implicit pointer conversions to and from void*....
Forum: C++ Oct 25th, 2007
Replies: 13
Solved: xor linked list
Views: 2,967
Posted By Ptolemy
>Doing a linked list using XOR ... I'm not certain what you mean.
It's a hack to avoid wasting extra space on links. It takes advantage of the butterfly effect using XOR. If you take the XOR of two...
Forum: C++ Oct 25th, 2007
Replies: 12
Solved: fibonacci
Views: 4,707
Posted By Ptolemy
>so changing the array to static solved everything.
No, changing the array to static and actually using the values you've cached solved everything. If you don't to the latter, your code won't be any...
Forum: C++ Oct 25th, 2007
Replies: 40
Solved: c++ scores
Views: 3,190
Posted By Ptolemy
>...Now where do i even begin?
You could use everything you've learned in your previous threads that do something similar.

>how do i store them so that the other lines are compared to it for the...
Forum: C++ Oct 25th, 2007
Replies: 12
Solved: fibonacci
Views: 4,707
Posted By Ptolemy
>And remember, the C++ standard includes the C standard, more or less.
Standard C++ currently maintains compatibility with C89, not C99. So you can't use VLAs in C++

>Is my program the best it...
Forum: C++ Oct 24th, 2007
Replies: 12
Solved: fibonacci
Views: 4,707
Posted By Ptolemy
>What about a purely iterative solution, that does not need the excess
>memory, and is not logically limited in the number of values to display?
That's fine for just printing the sequence. The...
Forum: C++ Oct 23rd, 2007
Replies: 2
Views: 533
Posted By Ptolemy
>i am currently getting 3 errors
They're telling you that you can't use an array as the condition for a switch statement. You can only use integral values (or char, because char is an integral type).
Forum: C++ Oct 23rd, 2007
Replies: 5
Views: 7,837
Posted By Ptolemy
>I would like to know once and for all how to convert a double to a const char*
Casting doesn't work. You're not converting the double to a string with a cast, you're telling the compiler to use the...
Forum: C++ Oct 22nd, 2007
Replies: 23
Views: 1,695
Posted By Ptolemy
>can u write the code so i know wat i need to change?
If I write it for you then you wouldn't need to change anything anymore. ;) Here's a super huge hint though:

double payRate[size];
double...
Forum: C++ Oct 22nd, 2007
Replies: 23
Views: 1,695
Posted By Ptolemy
>in order to calculate wages, i have tried following
I noticed that hours and payRate weren't ever initialized in your earlier code. If you don't ever put anything in those arrays, you're going to...
Forum: C++ Oct 22nd, 2007
Replies: 9
Views: 1,877
Posted By Ptolemy
Do you really want to be casting away the precision when you call abs? Maybe you should be using fabs instead so that it gives you the absolute value without losing the precision.
Forum: C++ Oct 22nd, 2007
Replies: 23
Views: 1,695
Posted By Ptolemy
>Is it really necessary to write your application in C or C++?
It's probably an assignment for a C++ course, so yea, I imagine it's really necessary. Why do you ask?
Forum: C++ Oct 22nd, 2007
Replies: 2
Views: 2,865
Posted By Ptolemy
You can use the standard time library to do it, sort of:

#include <ctime>
#include <iostream>

void long_running_operation()
{
for ( unsigned i = 1; i != 0; i++ )
;
}
Forum: C++ Oct 22nd, 2007
Replies: 3
Views: 3,499
Posted By Ptolemy
>.533 microns converted to miles per hour = 3.311908
>.674 microns converted to miles per hour = 4.188042
Well, first, you need to remove the "per hour" part of that. The conversion is strictly...
Forum: C++ Oct 22nd, 2007
Replies: 1
Views: 1,791
Posted By Ptolemy
>This program is suppose to add, subtract, and print the complex numbers.
It'd be 100% easier if you used the standard complex stuff from the <complex> header. Despite the name, it's actually quite...
Forum: C++ Oct 21st, 2007
Replies: 3
Views: 636
Posted By Ptolemy
>why does that matter anyway? i thought c++ is portable
C++ doesn't specify anything about hardware. When you step outside the bounds of the language definition, you lose the portability.
Forum: C++ Oct 21st, 2007
Replies: 4
Views: 2,060
Posted By Ptolemy
>It doesn't report any errors in scene.h, but here is the code anyway
Of course it doesn't. The errors don't manifest until the int main() { line. In this case because your typedef doesn't end with...
Forum: C++ Oct 21st, 2007
Replies: 4
Views: 2,060
Posted By Ptolemy
>Any ideas on how to fix this?
Nope. Clearly you have a syntax error in scene.h, but since you didn't post the contents, it's impossible to tell you what's wrong or how to fix it.
Forum: C++ Oct 21st, 2007
Replies: 2
Views: 1,439
Posted By Ptolemy
>}else(
That last character is a paren, not an opening brace.

>default;
That last character is a semicolon, not a colon.
Forum: C++ Oct 21st, 2007
Replies: 12
Views: 1,950
Posted By Ptolemy
Damn, I'm good. cin >> n; reads an integer, but leaves a newline on the stream. getline ( cin, N ); is supposed to stop reading when it finds a newline, so it looks like the call is getting skipped....
Forum: C++ Oct 21st, 2007
Replies: 12
Views: 1,950
Posted By Ptolemy
>I have used getline() but that didn't stop the compiler to get a value..
Post a full program that has the problem. I'm guessing that you have a cin>><blah> somewhere before the getline, and the...
Forum: C++ Oct 21st, 2007
Replies: 27
Views: 134,258
Posted By Ptolemy
>void main(){
main returns int. Since you can omit the return statement in C++, using int main on top of being correct and portable actually saves you one keystroke. It's a win-win situation. :)
Forum: C++ Oct 19th, 2007
Replies: 14
Views: 2,984
Posted By Ptolemy
That's not a good description of the algorithm. :( You want to loop as long as larger is greater than zero. You want to always double smaller and halve larger, and only add smaller to the accumulator...
Forum: C++ Oct 19th, 2007
Replies: 14
Views: 2,984
Posted By Ptolemy
That's a logic error. What is "Brown's method" supposed to be doing?
Forum: C++ Oct 19th, 2007
Replies: 14
Views: 2,984
Posted By Ptolemy
>As of now, the program only prints out :"Go again?".
It shouldn't print anything. That code won't compile because the braces are mismatched and functions don't nest inside of each other. This works...
Forum: C++ Oct 19th, 2007
Replies: 3
Views: 993
Posted By Ptolemy
>what i wanna know is how do you output the .65 kilograms
If you assign the value to an int, the fractional part is truncated. Subtract that from the original value and you get just the fractional...
Forum: C++ Oct 19th, 2007
Replies: 7
Views: 602
Posted By Ptolemy
You have a rogue opening brace in the Debit member function. Replace yours with this:

void Debit()
{
double amount2;

cout<< " please enter the value that you want to willdrow from your...
Showing results 1 to 37 of 37

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC