Forum: C Nov 2nd, 2008 |
| Replies: 4 Views: 1,391 And a little piece of advice. When working with decimal numbers, don't use float, instead use more precise double. |
Forum: C Oct 26th, 2008 |
| Replies: 10 Views: 2,562 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,562 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 20th, 2008 |
| Replies: 6 Views: 530 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: 24 Views: 8,719 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: 8,719 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 17th, 2008 |
| Replies: 6 Views: 791 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 16th, 2008 |
| Replies: 4 Views: 1,985 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 14th, 2008 |
| Replies: 10 Views: 869 Thank you for your answers :) |
Forum: C Oct 14th, 2008 |
| Replies: 10 Views: 869 @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 12th, 2008 |
| Replies: 10 Views: 840 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: 736 Flushes everything (like a damn good toilet :) ) |
Forum: C Oct 12th, 2008 |
| Replies: 7 Views: 487 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,079 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 11th, 2008 |
| Replies: 4 Views: 590 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 1st, 2008 |
| Replies: 9 Views: 2,185 This exact code works for me perfectly |
Forum: C Sep 30th, 2008 |
| Replies: 16 Views: 1,323 Two problems that I see.
What about your input code? First you ask user to insert "a and n", but using scanf() you first get n, then a. That could be problem.
And on end of int main() add return... |
Forum: C Sep 29th, 2008 |
| Replies: 16 Views: 1,323 Post entire code please. Once more :) |
Forum: C Sep 29th, 2008 |
| Replies: 16 Views: 1,323 Well, it says about 'n' not being initialised. Try to debug it yourself! |
Forum: C Sep 29th, 2008 |
| Replies: 16 Views: 1,323 On line 7 you have:
int power (int n); // function prototype
And later you call your function:
float power(float a, int n) |
Forum: C Sep 28th, 2008 |
| Replies: 12 Views: 1,151 Isn't negative factorial kind of wrong altogether? |
Forum: C Sep 28th, 2008 |
| Replies: 3 Views: 625 I don't see a problem. You don't need this piece of code:
{
int old_number= 0;
int current_number = 1;
int next_number;
} |
Forum: C Sep 27th, 2008 |
| Replies: 12 Views: 1,151 And why is it called return1??? It should be fact!!! |