Forum: C Jan 28th, 2009 |
| Replies: 5 Views: 415 That doesn't make much sense. What you said(IF you said what I think you said) can be achieved more conveniently using a loop. |
Forum: C Jan 28th, 2009 |
| Replies: 5 Views: 415 Use int main(), indent your code, use switch cases and a while loop instead of goto and if cases. |
Forum: C Dec 13th, 2008 |
| Replies: 5 Views: 956 Daniweb isn't a program spewing machine that you can command. |
Forum: C Dec 5th, 2008 |
| Replies: 4 Views: 632 Here's a useful link (http://www.java2s.com/Code/C/Development/Howtochecktheperformancedifftime.htm) |
Forum: C Dec 4th, 2008 |
| Replies: 4 Views: 522 This is wrong:
for(i = 0; i < n; i++){
for(j = 0; j < n; j++) printf(" %d", MatrixMult( a, b, c, &n ));
printf("\n");
}
You can't return arrays since they are always passed by... |
Forum: C Dec 4th, 2008 |
| Replies: 4 Views: 522 Better use fscanf() to read integers. If you use fgetc(), you'll be reading the ascii values of the integers and not their actual values. Also every digit will be treated as a character. How will you... |
Forum: C Dec 4th, 2008 |
| Replies: 10 Views: 961 That's quite a complex piece of code you got there. Since I'm still a beginner it took me quite a while to understand it's logic. I'm just surprised that you could come up with that logic and not be... |
Forum: C Dec 4th, 2008 |
| Replies: 10 Views: 961 Hmm. I guess I misjudged the working of fgetc(stdin). Will look that up. |
Forum: C Dec 4th, 2008 |
| Replies: 10 Views: 961 It usually happens if the string isn't NULL terminated. It would be easier to figure out your problem if you posted your code.
Also, in my previous code, you'll have to flush the input before... |
Forum: C Dec 4th, 2008 |
| Replies: 10 Views: 961 This is all you have to do to prompt the user till he enters a string with a period:
char msg[50];
int length = 0;
do
{
printf("Enter a string and end it with a period\n");... |
Forum: C Dec 2nd, 2008 |
| Replies: 5 Views: 1,087 Correct way of using code tags:
.
.
Your code here
.
. |
Forum: C Nov 29th, 2008 |
| Replies: 19 Views: 1,005 Appending a new employee to the should be easy. Declare a few "templates"(poor choice of word, perhaps) of string such as:
char empInfoTemp[] = "Employee ";
char nameTemp[]= " Name : ";
.
.... |
Forum: C Nov 25th, 2008 |
| Replies: 1 Views: 258 You declare it as an integer.
Ex:
int hex = 0xBCD;
printf("%x",hex); |
Forum: C Nov 24th, 2008 |
| Replies: 4 Views: 503 MNTABPTR is only a pointer whose size is 4 bytes(32-bit system). What you want is to allocate memory for the size of the structure MNT which is 132 bytes. For which you either do this:
newnode =... |
Forum: C Nov 17th, 2008 |
| Replies: 12 Views: 1,818 /* Allocate one item of the type p points to */
p = malloc ( sizeof *p );
That's looks like a really neat way of allocating memory, and I can see how it can be less error-prone. Thanks! |
Forum: C Nov 17th, 2008 |
| Replies: 12 Views: 1,818 malloc() always returns a void pointer. You need to typecast it. students = (struct student**)malloc(sizeof(struct student)); |
Forum: C Nov 16th, 2008 |
| Replies: 23 Views: 3,180 So your output is this:
*
***
*****
*******
No of starts: 1,3,5,7. |
Forum: C Nov 15th, 2008 |
| Replies: 23 Views: 3,180 It might work this time if the C compiler you are using grows sympathetic towards your blind persistence. |
Forum: C Nov 15th, 2008 |
| Replies: 23 Views: 3,180 That doesn't do any good.
Are you sure about the output?
1st row should have 1 asterisk, 2nd row should have 3, 3rd should have 4 and 4th row should have 6? |
Forum: C Nov 9th, 2008 |
| Replies: 2 Views: 1,730 The upper limit of an int is 2147483647(32-bit system). When x reaches the value 1073741824, x<<1; multiples that value by 2 which yields 2147483648 which is beyond the upper limit, hence the value... |
Forum: C Nov 1st, 2008 |
| Replies: 4 Views: 580 Do you want to do it just so you could justify it to the right? If so you could use this:
int i=444;
printf("%9d",i);
It won't include any zeroes at the beginning but it'll be right justified. |
Forum: C Oct 29th, 2008 |
| Replies: 9 Views: 829 Well, that i knew. I guess i just misinterpreted your previous post. :) |
Forum: C Oct 29th, 2008 |
| Replies: 9 Views: 829 I don't understand how that converts binary to decimal.
What's the significance of this piece of code?
for(i=0;i<8;i++){
if (input[i]!=48&&input[i]!=49){
... |
Forum: C Oct 19th, 2008 |
| Replies: 24 Views: 7,949 scanf ("%[^\n]", string);
scanf("%c", &dump);
Yeah, the above code will take in whitespaces as well. Or you could use gets() or fgets() to be safe.Reason not to use gets... |
Forum: C Oct 19th, 2008 |
| Replies: 24 Views: 7,949 You still haven't pointed out why you are passing a character array as an argument. And your result variable seems redundant too. And as Salem pointed out it can be done using %s in scanf()like this:... |
Forum: C Oct 8th, 2008 |
| Replies: 6 Views: 947 scanf ("%d", &a);
a is declared as a float, so %d should be %f.
Function definition-
int mypower(float a, int n);
there's no semicolon at the end. (as Salem pointed out.)
int power
return... |