Oh, so it's one's complement? I'll have to re-read that section. I really need to get a copy of "The C Answer Book" ;)
Thanks again, I really appreciate the help.
This is such a great book, I...
Type: Posts; User: zensatori
Oh, so it's one's complement? I'll have to re-read that section. I really need to get a copy of "The C Answer Book" ;)
Thanks again, I really appreciate the help.
This is such a great book, I...
I have not seen the ~0 or ~value before, where is that coming from? I have seen ~1 used to set boolean values before. I see how it works and it seems straigh forward but I would like to know more...
Got it! Thanks, I wrote out some sample code and tested the effects. I don't think I have ever read about that before, handy to know.
Where is the ~0UL coming from, is it part ot stdbool or something else. Thanks for the reply.
printf("%lu", ~0UL);
Can someone explane how this is working? Seems like this could be really handy to understand.
That is very helpful as are many of the suggestions. I guess I really don't understand stdbool. The man page it not particularly illuminating.
Thanks for the help.
How do I get printf to display the value?
In this case I am trying to figure out in code of the largest possible value of an unsigned long int. The problem is that if I just do the math 2^(whatever) i am bound to exceed the size of the value...
Could I take the stuff poped off the stack as chars and then check if they are operators? If not put them in temp ints and preform math on them? Problem I see with that is I am only checking a very...
Read the wikipedia stuff.
Does that ASCII solution still work for an input with larger numbers?
13241
184781
+
Can you tell me how this would look in RPN: 9 (4 - 2) / 4
Hey, I was just wondering if anyone could give me some suggestion on writing an RPN calc? I am using a double llist lib that I wrote to push and pop. Can anyone suggest how I can decide if I am...
I get an output like this when i time some functions
I will try %g and see what i get.
Yes... Thanks! I feel like a real n00b now.
edit: I just changed my output to printf to %f and I get 0.00000 also, same as the guy above. Suggestions?
edit edit: Never mind, i got it.
yeah, i know. I was just showing the syntax i am using. It is not mean as a exaple of my implimentation. Sorry i didn't make that clear and thanks for the suggestion.
Can someone give me a quick example of using time.h to time how long something runs for?
i would like to output in human readable time.
I was doing this:
clock_t start = clock();
...
Thanks for the suggestion. I kind of forgot that scanf returns anything :/
So, my malloc ing looks ok?
-bash-3.1$ ./proj1 < 100000.txt
463480570
Array at 101 = 463480570
*** glibc detected *** ./proj1: realloc(): invalid next size: 0x0969a008 ***
======= Backtrace: =========...
#include <stdio.h>
#include <stdbool.h>
#include "project1.h"
int main()
{
int i, r, NUM_ITEMS, t, ret, ava;
int* numbers;
NUM_ITEMS = 0;
int i, r, NUM_ITEMS, t, ret;
int* numbers;
NUM_ITEMS = 0;
while(((ret = scanf("%d",&t)) != EOF) && (ret != 0))
{
printf("%d\n",t);
numbers = malloc(1 * sizeof(int));...
This is what i have to do, I have everything else.
Thanks for the help.
int t;
while ( t != EOF )
{
scanf("%d", &t);
printf("%d", t);
}
Alright, then what is the terminating char that I base my loop on? And way not just malloc and realloc int by int untill EOF?
I need to create an array from user input on the fly.
I am just wondering if anyone can tell me, how is c handeling the input for the command line like this:
./arraycreate < input_100.txt
...