Search Results

Showing results 1 to 40 of 64
Search took 0.01 seconds.
Search: Posts Made By: Sci@phy
Forum: C++ Nov 13th, 2008
Replies: 9
Views: 938
Posted By Sci@phy
What have you done so far? We don't solve homeworks
Forum: C++ Nov 11th, 2008
Replies: 2
Views: 1,336
Posted By Sci@phy
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
Solved: Sine Series
Views: 1,289
Posted By Sci@phy
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
Posted By Sci@phy
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
Solved: Trie's in C
Views: 2,408
Posted By Sci@phy
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
Solved: Trie's in C
Views: 2,408
Posted By Sci@phy
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
Solved: And or not
Views: 977
Posted By Sci@phy
Ah, now you've said your problem. Solution is simple:
AND && (notice, two & signs)
OR ||
NOT !
Forum: C Oct 20th, 2008
Replies: 6
Solved: Help Please
Views: 520
Posted By Sci@phy
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
Solved: Syntax Error
Views: 303
Posted By Sci@phy
while( chioce != 'n' );}
should actually be:
} while( chioce != 'n' );

Have a nice coding :)
Forum: C Oct 19th, 2008
Replies: 24
Views: 7,888
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
Please mark this thread solved then
Forum: C++ Oct 16th, 2008
Replies: 9
Views: 712
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
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
Solved: printf
Views: 851
Posted By Sci@phy
Thank you for your answers :)
Forum: C Oct 14th, 2008
Replies: 10
Solved: printf
Views: 851
Posted By Sci@phy
@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
Solved: C++...
Views: 361
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
Flushes everything (like a damn good toilet :) )
Forum: C Oct 12th, 2008
Replies: 7
Solved: Weird error
Views: 475
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
It shouldn't happen, but this code isn't giving anything
Forum: C++ Oct 11th, 2008
Replies: 11
Views: 1,460
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
Post a small code where you are using your function, please
Forum: C Oct 11th, 2008
Replies: 4
Solved: scanf problem
Views: 576
Posted By Sci@phy
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
Posted By Sci@phy
Zip and post entire code, please.
It's frustrating me now too :)
Forum: C++ Oct 11th, 2008
Replies: 2
Solved: Scanf problem
Views: 470
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
(*this) is returned so you can write things like:
myObjA = myObjB = myObjC;
Forum: C++ Oct 11th, 2008
Replies: 11
Views: 1,371
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
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
Posted By Sci@phy
Ok, and you have just one slight error that programmers freak about. Instead of writing
void main(), consider using int main().
Showing results 1 to 40 of 64

 


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

©2003 - 2009 DaniWeb® LLC