Search Results

Showing results 1 to 40 of 76
Search took 0.11 seconds.
Search: Posts Made By: John A ; Forum: C and child forums
Forum: C Aug 1st, 2009
Replies: 9
Views: 381
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: 381
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 Apr 20th, 2009
Replies: 3
Views: 382
Posted By John A
Forum: C Apr 19th, 2009
Replies: 8
Views: 368
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 15th, 2009
Replies: 2
Views: 786
Posted By John A
printf takes a formatting string as its first parameter. You probably meant:
printf( "%d\n", bytes_received );
Forum: C Apr 10th, 2009
Replies: 11
Views: 720
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: 720
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: 720
Posted By John A
>Prototypes don't go inside other functions.
Wrong. Prototypes don't usually go inside other functions.
Forum: C Apr 7th, 2009
Replies: 14
Views: 755
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,487
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 5th, 2009
Replies: 57
Views: 2,487
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 4th, 2009
Replies: 57
Views: 2,487
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 3rd, 2009
Replies: 5
Views: 659
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: 301
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: 2
Views: 329
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: 790
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: 790
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: 790
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.
Forum: C Mar 31st, 2009
Replies: 11
Views: 790
Posted By John A
Just to show you how much performance you didn't gain by trying to optimize, I benchmarked your x_bzero() function against memset, each clearing out 100 kilobytes of data. memset is more than 10...
Forum: C Mar 31st, 2009
Replies: 11
Views: 790
Posted By John A
>since I'm zeroing 2 -> 8 bytes and rest I'm not zeroing, why my buffer is all zero?
It's not. It only zeroes out 8 bytes at a time. You probably assumed the entire string was zeroed when you tried...
Forum: C Mar 29th, 2009
Replies: 7
Views: 578
Posted By John A
So in your calling function, create an array with an arbitrary size large enough to hold all the inputs your program will ever use:
TypeAudioInput audioinputs[200];


Then you can pass an...
Forum: C Mar 28th, 2009
Replies: 7
Views: 578
Posted By John A
What are you trying to do? Variable names are largely irrelevant; they're just a means of accessing memory in your system. Learn about pointers and you'll understand how this works.
Forum: C Mar 10th, 2009
Replies: 17
Views: 909
Posted By John A
>}while(again != y && again != n);
You need to put single quotes around y and n.
Forum: C Mar 10th, 2009
Replies: 17
Views: 909
Posted By John A
Before your declarations you assigned 'choice' to 0. That counts as execution.
Forum: C Mar 8th, 2009
Replies: 17
Views: 909
Posted By John A
No, you're wrong, the OP is correct. The goal of the loop is to keep asking the user until valid input is entered (Y or N). The initial mistake was made by using OR instead of AND, because you want...
Forum: C Mar 7th, 2009
Replies: 17
Views: 909
Posted By John A
>theMenu[0].menuItem[LENGTH]=" [1] Chicken A";
That won't work either. You'll have to strcpy the strings into the character arrays, or point each node of menuItem to a string literal and then make...
Forum: C Mar 7th, 2009
Replies: 17
Views: 909
Posted By John A
>choice = getData(int);
You're getting the error because getData needs an actual integer to be passed to it. Then again, making getData() take parameters which it doesn't actually use makes no...
Forum: C May 8th, 2008
Replies: 2
Views: 638
Posted By John A
That's because the memory address contained in the pointer is lost when the function is popped off the stack. In other words, you can modify the value that the pointer points to, but you can't modify...
Forum: C May 1st, 2008
Replies: 6
Views: 748
Posted By John A
A couple of other notes:

- void main is evil (http://users.aber.ac.uk/auj/voidmain.shtml). Don't use it.
- You shouldn't have your function prototype inside main(). Move line 13 to somewhere...
Forum: C Mar 6th, 2008
Replies: 14
Views: 5,394
Posted By John A
>So Walt what you are saying...is that C doesn't support dynamic arrays????
Not in that way. If you want to dynamically allocate memory, you would have to use malloc or calloc to allocate a chunk of...
Forum: C Feb 24th, 2008
Replies: 10
Views: 2,088
Posted By John A
>i have no idea what ur suggestion changed, but i no longer get the error.
Most likely because Visual C++ 6.0 compiles under C code under the C89 standard. One of the rules in C89 is that all...
Forum: C Feb 23rd, 2008
Replies: 10
Views: 2,088
Posted By John A
Try putting the declaration of difflatt at the beginning of your program (before execution begins with printf).
Forum: C Feb 23rd, 2008
Replies: 10
Views: 2,088
Posted By John A
When I put the code into my compiler, I received the same errors you described. Funnily enough, when I removed the *s, those errors disappeared.
Forum: C Feb 20th, 2008
Replies: 3
Views: 529
Posted By John A
When you pass arrays, you pass the pointer, not the entire array. And you can't declare variables inside a function. Thus, your function call would look like:
sort_date(Acc, n);
Forum: C Feb 4th, 2008
Replies: 1
Views: 3,074
Posted By John A
The problem that you're experiencing is that getchar() only grabs a single character from the input buffer. This would be fine, except that there's still a newline left in the input buffer that...
Forum: C Jun 4th, 2007
Replies: 7
Views: 1,633
Posted By John A
Forum: C May 8th, 2007
Replies: 4
Views: 3,969
Posted By John A
You're getting the segmentation fault for because of this:
for(ptr=string;string!='\0';ptr++) Try replacing 'string' with *ptr (and remember, the * is important for dereferencing the value contained...
Forum: C May 8th, 2007
Replies: 12
Views: 4,615
Posted By John A
Can I have it? Pleeease? :icon_mrgreen:

As for the code, yuck. Even your input isn't correct, try allocating some memory first. And DO please listen to Salem's last suggestion, he basically handed...
Forum: C May 6th, 2007
Replies: 7
Views: 886
Posted By John A
>This code doesn't actually store anything in my array, does it?
Of course it does. You just aren't printing out any of the values you stored.

Try this at the end of GetID():

for (i=0;...
Forum: C May 6th, 2007
Replies: 7
Views: 886
Posted By John A
>GetID(students,StoreID[],i);
That's not how you pass arrays. Remove the [], and you'll pass the address of it.
Showing results 1 to 40 of 76

 


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

©2003 - 2009 DaniWeb® LLC