Forum: C 4 Days Ago |
| Replies: 7 Views: 221 man, when i was in the Navy, we had our BMI regularly measured. it used some other measurements like neck and waist but essentially the same.
there was a guy who had a BMI of 8 or 9. many of us... |
Forum: C 7 Days Ago |
| Replies: 5 Views: 275 if you want the capability of being able to shoot yourself in the foot, you can try
3. use fixed width records and one or more of "fseek", "ftell", "fsetpos", and "rewind" to manipulate the... |
Forum: C 7 Days Ago |
| Replies: 3 Views: 371 i don't really know what you're talking about, but thanks for posting your solution.
someone will wander across this someday and be helped by it.
:) |
Forum: C Oct 7th, 2009 |
| Replies: 7 Views: 302 you need to post a question if you want an answer. |
Forum: C Oct 5th, 2009 |
| Replies: 7 Views: 302 when you 'getch' you're taking the next character off of the input queue for processing.
this assumes once you've processed it, you're done with it, and will (probably) eventually want to get... |
Forum: C Aug 5th, 2009 |
| Replies: 13 Views: 783 the main() program can often be called by a parent program. 'return 0;' indicates to the caller (parent) that the main() program executed correctly.
so... generally speaking, the main function... |
Forum: C Jul 16th, 2009 |
| Replies: 18 Views: 690 the error is probably due to the fact that 'x' isn't initialized, so it's value is something like negative eleventy thousand, causing your program to crap the bed when it uses it as one of the array... |
Forum: C Jul 16th, 2009 |
| Replies: 18 Views: 690 you got both loops fighting over the same index 'i' |
Forum: C Jul 14th, 2009 |
| Replies: 30 Views: 1,639 this thread is a disaster. :)
you are a patient man, Salem.
. |
Forum: C Jul 13th, 2009 |
| Replies: 46 Views: 1,544 use code tags correctly. and make sure your code is indented. otherwise, it's a ridiculous mess, and no one will want to look at it.
int main(void)
{
// hello, i am properly formatted... |
Forum: C Jul 13th, 2009 |
| Replies: 30 Views: 1,639 |
Forum: C Jul 13th, 2009 |
| Replies: 30 Views: 1,639 yes, you're right.
even though it works for this trivial example, not casting it properly is a bad habit to get into.
the correct way to initialize it is:
char q[16];
char *p = (char... |
Forum: C Jul 13th, 2009 |
| Replies: 30 Views: 1,639 try this:
char q[16];
char *p = &q;
strcpy(q,"abc");
. |
Forum: C Jul 8th, 2009 |
| Replies: 16 Views: 890 this is not your thread to ask basic questions. go open your own thread on how to use IF.
and if you don't know how to use sscanf() -- much less how to look it up (http://lmgtfy.com/?q=sscanf)... |
Forum: C Jul 8th, 2009 |
| Replies: 16 Views: 890 what you have written here is an identifier from a #define'd constant -- not a string.
if it were a string, then you could use sscanf() as Tom Gunn suggested. but he's assumed that you really... |
Forum: C Jul 8th, 2009 |
| Replies: 3 Views: 643 your .NET installation is broken. Unless you're some sort of windows/.NET guru, the chance of you fixing it correctly is small.
uninstall all visual studio and .NET components, reboot, then... |
Forum: C Jul 6th, 2009 |
| Replies: 7 Views: 341 'k' is a pointer. meaning it describes, or "points to," an address of memory.
when you first declare this pointer, there is no memory allocated for it and the address that it points to is... |
Forum: C Jul 5th, 2009 |
| Replies: 12 Views: 547 that's one way to do it. I prefer to use "strtol()", because you can do more robust error checking to see if the user entered a valid number.
but sure... try "atoi()" to get started.
. |
Forum: C Jul 5th, 2009 |
| Replies: 12 Views: 547 fflush(stdin) is totally, utterly, and completely wrong.
never, ever, use it.
learn to parse your input correctly in the first place, and you wont have this problem.
so get rid of scanf()... |
Forum: C Jul 2nd, 2009 |
| Replies: 9 Views: 415 most of these trifling problems will go away when you throw away the P.O.S. Borland/Turbo compiler and get a real C/C++ compiler like CodeBlocks (http://www.codeblocks.org) or Bloodshed Dev C++... |
Forum: C Jul 2nd, 2009 |
| Replies: 3 Views: 925 the answer to your basic problem:
if isdigit(cResponse);
is incorrect. it should be
if (isdigit(cResponse))
{
// do stuff here
}
(1) an if-statement must be entirely enclosed in... |
Forum: C Jul 1st, 2009 |
| Replies: 21 Views: 1,210 or, conversely:
you post your code there, and wait for someone to make it better and hope some guy doesn't expect you to actually learn something, and you can just sit on your ass waiting for... |
Forum: C Jun 30th, 2009 |
| Replies: 21 Views: 1,210 i dont know what you did, but your code is not visible.
so, please use code tags.
put your code here |
Forum: C Jun 24th, 2009 |
| Replies: 10 Views: 623 EDIT: never mind. find it yourself. (http://lmgtfy.com/?q=mulitple+precision+library) |
Forum: C Jun 21st, 2009 |
| Replies: 4 Views: 465 what salem said.
and, anyhow, if you really want to do this correctly, you will use the standard C library <time.h> (http://www.cplusplus.com/reference/clibrary/ctime/) ... you will make use of... |
Forum: C Jun 20th, 2009 |
| Replies: 10 Views: 1,854 oh, hell, i just cut and pasted his code. i didn't even notice that
:) |
Forum: C Jun 20th, 2009 |
| Replies: 3 Views: 865 um... you pretty much just described the two steps.
$ gcc file1.c main.c
$ ./a.out
what more do you want to do? |
Forum: C Jun 19th, 2009 |
| Replies: 10 Views: 1,854 as already stated, never try to use strings as cases for a switch. Some languages (like Perl) will allow this. C will not.
you could, for instance, try something like this:
void... |
Forum: C Jun 19th, 2009 |
| Replies: 12 Views: 810 awesome!
sure can!
you're welcome! |
Forum: C Jun 17th, 2009 |
| Replies: 17 Views: 873 well, K&R is not really written for the beginner. It was written for people who were professional programmers in another language looking to learn the "new" language C.
obviously it's also... |
Forum: C Jun 16th, 2009 |
| Replies: 17 Views: 873 you did not implement it right.
before declaring it 'done', you need to test the program with known values and known solutions. like the one i described x=85, p=6, n=5, y=238 ... the result... |
Forum: C Jun 16th, 2009 |
| Replies: 17 Views: 873 why do a convoluted loop? the point, anyhow, is to learn bitwise operators. otherwise throw the chapter away and go learn about loops.
but i do see that i misunderstood part of the question. ... |
Forum: C Jun 16th, 2009 |
| Replies: 6 Views: 438 andy is damned and determined to pound those square pegs into some round holes.
bummer. i was looking forward to some cool Narue code.
. |
Forum: C Jun 16th, 2009 |
| Replies: 17 Views: 873 take the example: given x=0x55 (dec 85, binary 01010101), p=6, n=5, and y=0xEE (dec 238, binary 11101110)
what you want to happen is this:
x= 01010101 (0x55, dec 85)
p=6 ^ (bit #6)... |
Forum: C Jun 14th, 2009 |
| Replies: 8 Views: 432 ~(~0 << n) makes a bitmask of ones equal to the number 'n'. does this by first filling the integer full of ones, then shifting them to the left 'n' bits (filling lsb's with zeros), then inverts all... |
Forum: C Jun 12th, 2009 |
| Replies: 6 Views: 377 uh, yeah, i meant to say that the memory is allocated when the "program" is called.
but look if you want to be a pedant, then it's true there's no static array in the OP's snippet. what there is... |
Forum: C Jun 12th, 2009 |
| Replies: 6 Views: 377 short answer: static arrays are allocated when the function is called, at which point your variable is undefined. so the construct is illegal.
if you want to dynamically allocate arrays, you... |
Forum: C Jun 10th, 2009 |
| Replies: 18 Views: 867 yeah, it usually is, when you try and quit the internets. |
Forum: C Jun 9th, 2009 |
| Replies: 18 Views: 867 ^ so.... whatever happened to June 6th? |
Forum: C Jun 9th, 2009 |
| Replies: 5 Views: 535 |