Search Results

Showing results 1 to 40 of 350
Search took 0.06 seconds.
Search: Posts Made By: John A ; Forum: C and child forums
Forum: C Sep 4th, 2009
Replies: 2
Views: 286
Posted By John A
And you've posted a duplicate here: http://www.daniweb.com/forums/thread216071.html
Forum: C Aug 1st, 2009
Replies: 9
Views: 370
Posted By John A
Your program "hangs" here:
scanf(" %.2f", &bal);
Actually, it's not really hanging. It's just waiting for input.

I'd say you're making this more complicated than it needs to be. Use one balance...
Forum: C Aug 1st, 2009
Replies: 9
Views: 370
Posted By John A
If you have more than one statement within an if/else/else if, you need braces around the block.
if ( newBalance < 0)
{
printf("***I am sorry, you have bounced this check. $10 will be");
...
Forum: C Jul 28th, 2009
Replies: 1
Views: 256
Posted By John A
Forum: C Jul 22nd, 2009
Replies: 1
Views: 196
Posted By John A
In the first iteration of your while() loop, you divide the number by itself, which will always divide evenly, thus making your sum twice as large as it should be.
Forum: C May 23rd, 2009
Replies: 5
Views: 441
Posted By John A
You're just a disgrace to all the real trolls out there.
Forum: C May 18th, 2009
Replies: 13
Views: 1,218
Posted By John A
>Is it possible for the code to have bugs
Yes.

>y didn't it core dump on the cygwin too?
Different platform, different system, different architecture.

But if you *really* want to find out the...
Forum: C May 1st, 2009
Replies: 8
Views: 616
Posted By John A
else
{
return 0;
}

Is a logic error because you assume that if the first byte of each block are equal, the entire block of memory is the equal. "return 0" should be placed after...
Forum: C Apr 26th, 2009
Replies: 1
Views: 272
Posted By John A
That's incredibly vague, and in case you haven't noticed, we're not a homework writing service.
Forum: C Apr 20th, 2009
Replies: 3
Views: 365
Posted By John A
Forum: C Apr 19th, 2009
Replies: 8
Views: 353
Posted By John A
The real reason you're having problems with your code is you're trying to modify a string literal:
>printf("ID: %d\n", getCommandId("move"));

You never allocated space for "move", so who knows...
Forum: C Apr 18th, 2009
Replies: 2
Views: 322
Posted By John A
Use pipes (http://opengroup.org/onlinepubs/007908775/xsh/popen.html).

Even better, use the POSIX libraries to create your own ls() function:...
Forum: C Apr 16th, 2009
Replies: 1
Views: 271
Posted By John A
C(n,r) can be calculated as follows:
C(n,r) = \frac{n!}{(n-r)!r!}

Which means your horizontal component would be 'r', and your vertical component 'n'.
Forum: C Apr 15th, 2009
Replies: 2
Views: 709
Posted By John A
printf takes a formatting string as its first parameter. You probably meant:
printf( "%d\n", bytes_received );
Forum: C Apr 13th, 2009
Replies: 24
Views: 774
Posted By John A
jepthah is right, there's far too much proprietary code for anyone here to help you. Not to mention fflush(stdin), and fixing your program so you don't require that could take quite some time. I will...
Forum: C Apr 12th, 2009
Replies: 35
Views: 1,823
Posted By John A
>okay, I'm going to stop arguing this because you guys are technically more
>precise than I am.
Never mind us nitpicks, we thrive off others' inaccuracies (however minor they may be) :P
Forum: C Apr 12th, 2009
Replies: 35
Views: 1,823
Posted By John A
>at least one authority -- the GNU C Library Manual --
>suggests that using EOF macro is not reccommended:
The only reason they don't recommend the EOF macro is because it doesn't differentiate...
Forum: C Apr 12th, 2009
Replies: 35
Views: 1,823
Posted By John A
You seem to have misunderstood me. I was not condoning nor recommending the code that I posted; the sole purpose was to help others understand why using feof() in a loop condition is not particularly...
Forum: C Apr 12th, 2009
Replies: 35
Views: 1,823
Posted By John A
That's not entirely true:

fgets( buffer, sizeof(buffer), file );
while( !feof(file) )
{
/* do whatever with buffer here */

fgets( buffer, sizeof(buffer), file );
}
Forum: C Apr 11th, 2009
Replies: 35
Views: 1,823
Posted By John A
>as for the EOF macro, it's not standardized.
Actually it is.

>It can have different values depending on compiler.
That's why it's a macro. If fgetc encounters the end of the file, it will...
Forum: C Apr 10th, 2009
Replies: 11
Views: 704
Posted By John A
>In the interest of not entering a pissing contest I am going to leave it at that.
Just because you're wrong doesn't mean I hate you. :P
Forum: C Apr 10th, 2009
Replies: 11
Views: 704
Posted By John A
>And your correction as the italicized exception, product of bad practice.
While you're entitled to your own opinion, that statement is just BS. There are perfectly acceptable reasons why you would...
Forum: C Apr 10th, 2009
Replies: 11
Views: 704
Posted By John A
>Prototypes don't go inside other functions.
Wrong. Prototypes don't usually go inside other functions.
Forum: C Apr 8th, 2009
Replies: 9
Views: 566
Posted By John A
>however do you think would work if I did something crazy like
>char string [] = getstring(15);
No, you can't initialize an array with a memory address. That's what pointers are for.
Forum: C Apr 7th, 2009
Replies: 14
Views: 708
Posted By John A
>sure you can write a program with conio.h, but it will be broken on most every
>non-microsoft systems.
And you can write a termios.h solution that will be broken on every non-POSIX system....
Forum: C Apr 7th, 2009
Replies: 57
Views: 2,428
Posted By John A
You forgot to allocate memory for your structures. Yes, you're allocating memory for the pointers inside the objects, but before you can do that you need to allocate memory for the entire object....
Forum: C Apr 6th, 2009
Replies: 7
Views: 687
Posted By John A
Forum: C Apr 5th, 2009
Replies: 57
Views: 2,428
Posted By John A
No. The purpose of a struct is so that you can keep numerous sets of data organized. You can now do the following:

struct Object3D* box;
struct Object3D* table;

Change functions that modify...
Forum: C Apr 5th, 2009
Replies: 2
Views: 494
Posted By John A
Good luck. You'll need it.
Forum: C Apr 4th, 2009
Replies: 7
Views: 687
Posted By John A
How about
void analyze( struct Crypt key[] )
{
...
}

Although not required, you should pass the size of the array, too:
void analyze ( struct Crypt key[], int size )

This way the...
Forum: C Apr 4th, 2009
Replies: 57
Views: 2,428
Posted By John A
Make a structure for your objects:
struct Object3D {
int ***facets;
float ***vertices;
int *nFacets;
int *nVertices;
int numObjects;

... /* add all variables specific to your...
Forum: C Apr 4th, 2009
Replies: 4
Views: 913
Posted By John A
>does it just substitute an answer for the first time the script hits a scanf function?
That's one way of thinking of it. 'stdin' becomes a file handle to the input file. The same rules apply when...
Forum: C Apr 4th, 2009
Replies: 4
Views: 913
Posted By John A
This doesn't have anything to do with C, but your shell. For example:
$ some_program < input_file

When some_program reads from stdin, it will be reading the contents of input_file.
Forum: C Apr 3rd, 2009
Replies: 5
Views: 605
Posted By John A
I have no idea what you mean by 'classes' (are you really programming in C?), but in general you should put structures and function prototypes in your headers, then #include them into whatever...
Forum: C Apr 3rd, 2009
Replies: 3
Solved: Command line
Views: 292
Posted By John A
Try converting the string to a long int first with strtol():
val = strtol( argv[1], NULL, 10 );

It's also a good idea to set errno=0 before calling the function; you can then check it afterward...
Forum: C Apr 2nd, 2009
Replies: 18
Views: 1,430
Posted By John A
>Technically speaking, I initialize and reinitiaize str pointer with every word I read from file.
You clearly don't understand how memory works in C. Either you use static memory, in which case the...
Forum: C Apr 2nd, 2009
Replies: 2
Views: 317
Posted By John A
You've got smart quotes “ instead of straight quotes ". Did you write that code in a word processor?
Forum: C Apr 1st, 2009
Replies: 11
Views: 770
Posted By John A
>am I correct?
Let's put it this way. Forget the pointers, below is a decimal representation of some memory, each value is one byte (so each value can hold 256 different values, in this case 0-255)....
Forum: C Apr 1st, 2009
Replies: 11
Views: 770
Posted By John A
>So now when i'm casting buffer void *s to long long, what would happen to that 5 bytes
Nothing. In 32 bit software, pointers are always 4 bytes. When you're casting pointer types, the compiler...
Forum: C Mar 31st, 2009
Replies: 11
Views: 770
Posted By John A
>well.... maybe it's a pedantic exercise assigned by his professor?
If that were the case, performance wouldn't be an issue in the first place.
Showing results 1 to 40 of 350

 


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

©2003 - 2009 DaniWeb® LLC