Forum: C Aug 31st, 2009 |
| Replies: 2 Views: 224 This page (http://www.instant-registry-fixes.org/troubleshooting-and-preventing-ntdlldll-errors/) says that ntdll.dll is "a Native API file of Microsoft operating systems and it contains NT kernel... |
Forum: C Aug 31st, 2009 |
| Replies: 2 Views: 264 char filenames[fcount][16];
You're declaring a variable-length array here. It's not standard C89 to do that. If I were you I'd just declare the array as
char filenames[MAX_FCOUNT][16];
Also:
... |
Forum: C Aug 31st, 2009 |
| Replies: 2 Views: 213 You can't assign anything inside a structure declaration. A structure declaration just defines a type. It's like a blueprint; you're telling the compiler, "if I ask you to create a Something, this is... |
Forum: C Jun 8th, 2009 |
| Replies: 14 Views: 852 Well, it has one advantage over a return value -- you have to pass in an address, whereas you could ignore a return value. :) I don't think that's how I would write it, though. |
Forum: C Sep 6th, 2008 |
| Replies: 1 Views: 796 Why is root a global variable? As far as I can see, it doesn't need to be, and it's just causing confusion because several functions take a root parameter. |
Forum: C Sep 4th, 2008 |
| Replies: 11 Views: 1,886 Declaring variables inside for loop initialization sections is indeed C99-only. I wouldn't do it if I were you.
double just has more precision (usually). Oftentimes, a float is 4 bytes and a... |
Forum: C Aug 13th, 2008 |
| Replies: 14 Views: 1,303 You can even use fancy preprocessor macros and so on to replace the malloc()/free() calls in existing code with your own functions.
BTW, __LINE__, __FILE__, __DATE__, and __TIME__ are all standard... |
Forum: C Aug 13th, 2008 |
| Replies: 4 Views: 1,702 Why don't you use the quadratic formula (http://en.wikipedia.org/wiki/Quadratic_equation#Quadratic_formula)? If all of the equations are quadratic, it should work.
You can do square roots in C... |
Forum: C Aug 13th, 2008 |
| Replies: 4 Views: 662 /* replaced 0 by 1 */
Depending on who you ask, the first fibonacci number can be 0 or 1. (Personally, I'd agree with you and have it 1.)
Why not use more descriptive names than num1, num2, etc? |
Forum: C Aug 13th, 2008 |
| Replies: 4 Views: 662 if(fib = fnum)
Try ==. = is for assignment, == is for comparison. (Your compiler should warn you about this if you enable warnings.)
Plus I don't think this is what you want.
for (fib=1;... |
Forum: C Aug 5th, 2008 |
| Replies: 10 Views: 998 You don't want a semicolon after a while loop:
while( number<= 0 ); {
->
while( number<= 0 ) { |
Forum: C Jul 22nd, 2008 |
| Replies: 10 Views: 2,707 My only suggestion is to try a profiler so that you can see exactly where your program is spending all of its time. If you have access to the code from the other program, profiling it as well might... |
Forum: C Jul 22nd, 2008 |
| Replies: 3 Views: 510 What are you forgetting here?
for(j=0;j<41;j++)
for(i=0;i<79;)
txt[j][i]=32;
Hint: it's an infinite loop . . . .
And it's a lot easier to use character constants like ' ' and '\r' in your... |
Forum: C Jul 22nd, 2008 |
| Replies: 2 Views: 507 You could save the numbers as you find them instead of printing them, say in a char array, and then print that array in reverse. On the other hand, it would probably be better to use a different... |
Forum: C Jul 22nd, 2008 |
| Replies: 10 Views: 956 @Adak: I already mentioned that, though admittedly it was buried in my long post.
The main logical problem with your code still exists. Numbers aren't the same thing as strings. You can't have an... |
Forum: C Jul 16th, 2008 |
| Replies: 7 Views: 1,990 for loops generally have three sections. You've forgotten the increment section. :)
You're also missing a closing parentheses on the strlen() call . . . .
But we know what you mean. :)
char... |
Forum: C Jul 16th, 2008 |
| Replies: 8 Views: 1,806 Yeah, most of the time it's a good idea. Sorry I didn't explain it further.
Yes. Accessing such memory could lead to data corruption or at the very least segmentation faults.
Correct.
... |
Forum: C Jul 16th, 2008 |
| Replies: 3 Views: 1,211 while( line % 55 != 0 )
Note that 0 % 55 is 0, so you'll pause before printing anything, and then display 55 lines ad infinitum. The best solution is probably to use something like this:
while(... |
Forum: C Jul 16th, 2008 |
| Replies: 10 Views: 956 That last post was getting crowded so I thought I'd start another one -- especially since it's a higher-level one.
Since you're trying to handle both numbers and strings, why not have two separate... |
Forum: C Jul 16th, 2008 |
| Replies: 10 Views: 956 GCC doesn't like your code.
sort.c: In function ‘read_list’:
sort.c:13: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘int *’
sort.c: In function ‘insert_sort’:
sort.c:75:... |
Forum: C Jul 16th, 2008 |
| Replies: 5 Views: 4,953 You can read image files in your program in a standard way, if you want to write the reader yourself. wotsit.org is a good reference for this, as already mentioned.
Or you can use a library to... |
Forum: C Jul 16th, 2008 |
| Replies: 8 Views: 1,806 ex_1.emotion_options = (char **)malloc(sizeof(char *[MAX_EMOTION_SIZE]));
That's uninitialized, so if you don't fill in MAX_EMOTION_SIZE elements of that array, then this will be freeing random... |
Forum: C Jul 4th, 2008 |
| Replies: 3 Views: 686 Well, if you think it makes the program easier to understand, then what can I say? :)
I really do think that there must be a better way, but unless you post some real code I probably won't think... |
Forum: C Jul 2nd, 2008 |
| Replies: 15 Views: 4,012 puts("Give me input numbers, each separated by space."); //gcc error: puts was not declared within this scope
You need to #include <stdio.h>, because that's where puts() is located.
The current... |
Forum: C Jul 2nd, 2008 |
| Replies: 24 Views: 2,759 Sorry to go behind jephthah's back here, but if this is your original structure
typedef struct ip_header{
unsigned char headlen:4; // header len
unsigned char ver:4; // version
unsigned... |
Forum: C Jul 2nd, 2008 |
| Replies: 8 Views: 3,508 So does Perl! In fact, you can do it with just one line, on the command line.
perl -pe 's/\s/g'
But that's beside the point.
Note that ssharish's code works, but it might be more efficient to... |
Forum: C Jul 2nd, 2008 |
| Replies: 3 Views: 686 It seems to me that .h files would be better for this, if all you're doing is managing constants (and not actual executable code).
The standard place to include header files, of course, is at the... |
Forum: C Jul 2nd, 2008 |
| Replies: 8 Views: 689 Don't forget Dev-C++: http://bloodshed/net/devcpp.html
But I doubt that's the problem, if Ancient Dragon encountered the same issue. |
Forum: C Feb 6th, 2008 |
| Replies: 4 Views: 559 Well, if
then you're out of luck, because, as you say, those numbers could not fit into a 32-bit integer.
On the other hand, if you want one of your structures as the result . . .
If the... |
Forum: C Oct 20th, 2007 |
| Replies: 6 Views: 790 switch ( Key ) {
case 'R':
case 'r':
Key_r();
break;
case 's':
case 'S':
Key_s();
break;
case 27: |
Forum: C Oct 20th, 2007 |
| Replies: 13 Views: 4,716 Something like this. I've glossed over details that you seem to already understand.
Declare an array to hold the letter counts one element for each letter, with each element initialized to zero.... |
Forum: C Oct 20th, 2007 |
| Replies: 8 Views: 3,990 Use code tags when you post code -- otherwise it will be an unreadable mess.
This is also the C programming forum, not the C++ one, so C++ code is out of place.
It's also old-style C++ code.... |
Forum: C Oct 20th, 2007 |
| Replies: 6 Views: 1,447 gotoxy() is an ancient Borland function. It's very unportable. No new code should use it or anything from <conio.h>, such as getch() or clrscr().
'a' is a single character. "a" is a string. Use... |
Forum: C Oct 20th, 2007 |
| Replies: 4 Views: 855 You're also
using void main(), which is non-standard;
using while(!feof(fp)), which reads too far;
not checking if your program was passed enough parameters, so argv[1] and argv[2] might not... |
Forum: C Oct 20th, 2007 |
| Replies: 4 Views: 2,615 You're looking in the wrong section of the manual. You don't want to create a vector view. Check out this section: http://www.gnu.org/software/gsl/manual/html_node/Accessing-matrix-elements.html
I... |
Forum: C Oct 20th, 2007 |
| Replies: 13 Views: 4,716 if(letter[i]==str[count])
Think about what you are doing here. You're saying something to the effect of, "if the i-th element of letter[] equals the count-th element of str[] ...". Since you've... |
Forum: C Oct 20th, 2007 |
| Replies: 1 Views: 1,665 Perhaps you should have a look at this. http://en.wikipedia.org/wiki/Floating_point#Normalization |
Forum: C Oct 20th, 2007 |
| Replies: 7 Views: 862 TRUE is a commonly-defined constant -- windows.h defines it, along with a whole host of other libraries. true is a C++ keyword, and a C99 keyword if you include <stdbool.h>.
So in ordinary, ANSI... |
Forum: C Oct 20th, 2007 |
| Replies: 5 Views: 3,026 Not quite. That only works if you had gone one past the maximum allowed value. If you can add more than 1, you need to do this:
If you can add more than the maximum range -- in other words, if you... |
Forum: C Oct 20th, 2007 |
| Replies: 2 Views: 1,142 You can also set the arguments to your program without actually running the program, such as right at the beginning before you forget, with "set args parameters". This is also the easiest way to... |