Forum: C++ Nov 13th, 2008 |
| Replies: 9 Views: 938 What have you done so far? We don't solve homeworks |
Forum: C++ Nov 11th, 2008 |
| Replies: 2 Views: 1,336 Well, you obvioulsy need to increment counter each time you add a node, and decrement it each time you remove a node. It's really not hard, just put it in insert, delete, and create list.
For... |
Forum: C Nov 2nd, 2008 |
| Replies: 4 Views: 1,289 And a little piece of advice. When working with decimal numbers, don't use float, instead use more precise double. |
Forum: C++ Oct 29th, 2008 |
| Replies: 8 Views: 611 Try to see if the problem is input or your class.
Remove all user inputs from main and put something yourself in it. If it works, problem is only in input. |
Forum: C Oct 26th, 2008 |
| Replies: 10 Views: 2,408 Do you know why do you use typedef?
It's syntax should be:
typedef some huge type A_DEF;
And the code you wrote has no use from typedef since you haven't specified name that will replace... |
Forum: C Oct 26th, 2008 |
| Replies: 10 Views: 2,408 Funny:
typedef struct node {
char value;
bool isroot;
bool isend;
struct node* sibling;
struct node* child;
}; //<== if semicolon goes here, it's much more reasonable |
Forum: C++ Oct 24th, 2008 |
| Replies: 15 Views: 977 Ah, now you've said your problem. Solution is simple:
AND && (notice, two & signs)
OR ||
NOT ! |
Forum: C Oct 20th, 2008 |
| Replies: 6 Views: 520 Although, if you're doing it for class of some sort, wouldn't it be better to make your own toupper? Just a thought.
Remember, letters are stored actually as ascii code, and you can "add" them or... |
Forum: C++ Oct 19th, 2008 |
| Replies: 2 Views: 303 while( chioce != 'n' );}
should actually be:
} while( chioce != 'n' );
Have a nice coding :) |
Forum: C Oct 19th, 2008 |
| Replies: 24 Views: 7,888 Ahh, I knew someone will say something like that :)
Of course it can be dangerous, so are pointers (but we still use those).
For first this I have only one answer: scanf("%40s", string);
For... |
Forum: C Oct 19th, 2008 |
| Replies: 24 Views: 7,888 And yet, scanf can be clever function:
#include <stdio.h>
int main(){
char dump, string[40];
printf("Enter whole sentece (yeah, bring spaces too, I can handle it):\n");
scanf... |
Forum: C++ Oct 19th, 2008 |
| Replies: 8 Views: 571 Remember that array is double pointer, just like ar. You cannot write ar[x], it is 2D array: ar[x][y]! |
Forum: C Oct 17th, 2008 |
| Replies: 6 Views: 770 The only reason this code should give you error is if you input something else that float, let's say letter. So please post what number did you entered for its first input?
And please, write:
int... |
Forum: C++ Oct 17th, 2008 |
| Replies: 2 Views: 1,224 Please mark this thread solved then |
Forum: C++ Oct 16th, 2008 |
| Replies: 9 Views: 712 THIS compiled ok on dev-cpp:
int main()
{
DWORD dwThreadId;
HANDLE myThread;
void *ptr=NULL;
myThread = CreateThread(
NULL, |
Forum: C Oct 16th, 2008 |
| Replies: 4 Views: 1,877 You could write your hex-to-deci function, and then you can simply write
char a = hex-to-deci-function(hex_num) |
Forum: C++ Oct 15th, 2008 |
| Replies: 2 Views: 416 If you want to determine n-th digit (from the back, so second digit in 1234 is 3) in a number, you do this:
a = number%(10^n) (now your digit is in first place)
digit = a/(10^(n-1)) (now everything... |
Forum: C Oct 14th, 2008 |
| Replies: 10 Views: 851 Thank you for your answers :) |
Forum: C Oct 14th, 2008 |
| Replies: 10 Views: 851 @Narue
I see you are using goto.
And I know programmers don't like to use goto, so if I may ask: why? :)
Did you just use it because it's fastest to write code like that?
Or would you still use... |
Forum: C++ Oct 14th, 2008 |
| Replies: 5 Views: 361 You have to pass variables as an argument.
If you want to pass one argument of type char to a function that returns bool you declare function:
bool Foo(char a_char)
And you call that function... |
Forum: C++ Oct 13th, 2008 |
| Replies: 8 Views: 571 int a[m][m]
int *ptr = a;
int **ptr = ptr[m];
This doesn't make any sense. If you have to assign dynamic memory, you cannot type int a[m][m];.
Yes, you have to use pointers. Don't worry,... |
Forum: C Oct 12th, 2008 |
| Replies: 10 Views: 825 It goes like this:
n(0) = 1;
n(1) = 1;
n(2) = n(1), n(2) //so it's actually two numbers
n(3) = n(1), n(2), n(3)...
Bottom line is: First two numbers just copy.
The print others in a for loop |
Forum: C Oct 12th, 2008 |
| Replies: 6 Views: 732 Flushes everything (like a damn good toilet :) ) |
Forum: C Oct 12th, 2008 |
| Replies: 7 Views: 475 Just some literature from wikipedia:
"In C99, there is a bool type, along with the values true and false, defined in the <stdbool.h>" |
Forum: C Oct 12th, 2008 |
| Replies: 15 Views: 1,062 On line 22 you are declaring function. There's no semicolon in the end.
Main is also a function. Do you write: int main(); |
Forum: C++ Oct 12th, 2008 |
| Replies: 8 Views: 621 It shouldn't happen, but this code isn't giving anything |
Forum: C++ Oct 11th, 2008 |
| Replies: 11 Views: 1,460 Huh? ifstream function cannot give ofstream error.
Be sure that you've changed declarations in header file too!
And no, you don't need to make private variables references. Only the function... |
Forum: C++ Oct 11th, 2008 |
| Replies: 11 Views: 1,460 Like twomers said, just try to return them as references:
ifstream& FileHandler::getFileIn()const{
return fileIn;
} |
Forum: C++ Oct 11th, 2008 |
| Replies: 11 Views: 1,460 Post a small code where you are using your function, please |
Forum: C Oct 11th, 2008 |
| Replies: 4 Views: 576 I doubt that IT printed out properly. Maybe you retyped it, because on my compiler (gcc) problem is with blank space after last %d that exists in his code, and so scanf asks for continuation of... |
Forum: C++ Oct 11th, 2008 |
| Replies: 11 Views: 1,371 Zip and post entire code, please.
It's frustrating me now too :) |
Forum: C++ Oct 11th, 2008 |
| Replies: 2 Views: 470 First: this is not C++ program!
Second: scanf_s - what kind of function is that? I don't know, maybe it exists, but I've heard only of scanf.
Third: solution is simple, remove blank space between... |
Forum: C++ Oct 11th, 2008 |
| Replies: 11 Views: 1,371 I'm not sure about this.
Function can access IT'S own members (this->memb1; this->memb2;)
But I'm really not sure about accessing other instance of same type...
Maybe your problem is in... |
Forum: C++ Oct 11th, 2008 |
| Replies: 11 Views: 1,371 (*this) is returned so you can write things like:
myObjA = myObjB = myObjC; |
Forum: C++ Oct 11th, 2008 |
| Replies: 11 Views: 1,371 Are you sure this code works:
ll = queue.ll;
'll' is under private section, right? I'm not sure if you can access it.
Here's my code example if it helps:
//operators
//=
Complex&... |
Forum: C++ Oct 11th, 2008 |
| Replies: 3 Views: 428 Some changes:
#include <iostream>
using namespace std;
const int MAX = 5, MAX2 = 3;
class notebook {
int num;
public :
notebook (); //this is wrong. Either write some... |
Forum: C++ Oct 8th, 2008 |
| Replies: 8 Views: 486 You obviously have three options about kwh, and using if-else is wrong approach.
Instead use:
if (kwh <= 20){
//do some coding here
}
else if (kwh > 20 && kwh <= 40){
//do other... |
Forum: C++ Oct 6th, 2008 |
| Replies: 2 Views: 364 I made slight adjustment:
sky.erase(sky.begin()+x);
More on: http://www.cplusplus.com/reference/string/string/erase.html
EDIT: oh yes, x <= sky.size() is wrong, should be x < sky.size() |
Forum: C++ Oct 5th, 2008 |
| Replies: 18 Views: 1,163 Simplyfied, there is some "GODlike" program that starts your C++ code:
int a = main();
//do stuff with a
If you write "void main()" variable a will be garbage.
MOST of the time, it doesn't... |
Forum: C++ Oct 5th, 2008 |
| Replies: 18 Views: 1,163 Ok, and you have just one slight error that programmers freak about. Instead of writing
void main(), consider using int main(). |