Posts
 
Reputation
Joined
Last Seen
Ranked #590
Strength to Increase Rep
+5
Strength to Decrease Rep
-1
100% Quality Score
Upvotes Received
3
Posts with Upvotes
3
Upvoting Members
3
Downvotes Received
0
Posts with Downvotes
0
Downvoting Members
0
2 Commented Posts
~50.7K People Reached
Favorite Tags
Member Avatar for Jammie

Well, this isn't at the bitlevel, you are interpreting the ascii values '0' '1' as bit 0 and bit 1. If you are interested in this bitlevel stuff, you should look into the shift operations. like [CODE=c++] unsigned char x=7; unsigned char y=x<<1; //y is now 7 times 2 [/CODE] …

Member Avatar for arunsolo1984
1
978
Member Avatar for drdaco

So you essentially want a truthtable. The dimension of this truthtable is n*2^n, where n is the number of coin throws. I once did this program, and I have to agree with you, it was annoyingly difficult to come up with, and I never had a beautifull solution. I think …

Member Avatar for Adak
0
245
Member Avatar for kookai

A commen misunderstanding is that the closed form version, is an approximation. For integers, it will be just as accurate as the iterative or recursive version.

Member Avatar for Nick Evan
0
2K
Member Avatar for csinquirer
Member Avatar for monkey_king

I'm having difficulties understanding and printing the max value of a size_t type. Apparantly the size_t is typedefed to a unsigned long int on my system. Is this safe to assume its the same on all c++ compilers? The 'sizeof' function returns the number of bytes(size char), used to represent …

Member Avatar for idallen
0
1K
Member Avatar for wiglaf
Member Avatar for jp071

Run it through a debugger assuming you are using gcc [QUOTE] $gcc -ggdb file.c $gdb ./a.out $run $bt [/QUOTE] This will tell you on which line the error originated. You can also look into valgrind good luck

Member Avatar for jp071
0
249
Member Avatar for monkey_king

Hi, Can someone elaborate why the following (the if conditional) differs [CODE=c] int main(){ const char *filename = "test.txt"; int ifd; if((ifd=open(filename,O_RDONLY))<3) err(EX_NOINPUT, "%s", filename); fprintf(stderr,"ifd is:%d\n",ifd); off_t bytes_in = lseek(ifd, (off_t)(-4), SEEK_END); return 0; } [/CODE] vs [CODE=c] int main(){ const char *filename = "test.txt"; int ifd; if(ifd=open(filename,O_RDONLY)<3) err(EX_NOINPUT, …

Member Avatar for monkey_king
0
122
Member Avatar for monkey_king

Hi I've found a strange problem on ubuntu64bit, that limits the data you are allowed to allocate on a 64bit platform using the c function 'read()' The following program wont allow to allocate more that 2.1gig memory. [CODE=c++] #include <stdio.h> #include <stdlib.h> #include <err.h> #include <fcntl.h> #include <sysexits.h> #include <unistd.h> …

Member Avatar for monkey_king
0
142
Member Avatar for monkey_king

I've been programmin on and off for some time. But today I saw something I hadnt seen before Some thing like [CODE=c] void error OF((const char *msg)); void gz_compress OF((FILE *in, gzFile out)); #ifdef USE_MMAP int gz_compress_mmap OF((FILE *in, gzFile out)); #endif void gz_uncompress OF((gzFile in, FILE *out)); void file_compress …

Member Avatar for jonsca
0
133
Member Avatar for timtianchen

There shouldn't be anything wrong with returning a 2-dim array. Something like the following should work. [CODE=c++] #include <iostream> #include <string> std::string **getstring(int x, int y){ std::string **var = new std::string*[x]; for (int i=0;i<x;i++) var[i]=new std::string[y]; return var; } int main(){ std::string **tmp = getstring(5,10); return 0; } [/CODE] This …

Member Avatar for monkey_king
0
145
Member Avatar for marirs07

I have no idea what you are asking. what do you mean by "running online"

Member Avatar for restrictment
-2
74
Member Avatar for arshad115

goto's can only jump to labels within the same function, so I don't think you will be able to do it with goto's if you are in some far away function. There are any beautifull way of doing what you want without having to redesign you program or use c++ …

Member Avatar for Cokaric
0
6K
Member Avatar for dchunt

If the size is determined at runtime you need a full fleged dynamic memory version. Something like [CODE=c++] #include <iostream> int **allocs(int x,int y){ int **ret = new int*[x]; for(int i=0;i<x;i++) ret[i] = new int[y]; return ret; } int main(){ int **array = allocs(4,5); int p = 0; for(int i=0;i<4;i++) …

Member Avatar for Tom Gunn
0
153
Member Avatar for ladykaelin

Just try to do the program, when its done, it should be clear what should be pointers.

Member Avatar for monkey_king
0
111
Member Avatar for umair125

Hi omir People are normally quite friendly inhere, but you should ask a specific question. good luck

Member Avatar for Ancient Dragon
-1
478
Member Avatar for monkey_king

If I simply just want to tokenize the first element of a string and then output the remainder of the string, how can this be accomplished? thanks [CODE=c] #include <stdio.h> #include <string.h> int main(){ const char* line= "0 firstline"; char* l = strdup(line); printf("beforeToknization:\t%s\n",l); char *tok = strtok(l," "); printf("firstToken:%s\trestOfLine:%s\n",tok,l); …

Member Avatar for jephthah
0
3K
Member Avatar for monkey_king

Hi I got a code that in pseudo dos something like [CODE] ifstream os; while(os.oef()){ os.getline(buffer,length); } [/CODE] If some condition is met, I'd like to be able to jump back to the previous line, such that the next getline will give the line just-read in, at a later time …

Member Avatar for tux4life
0
476
Member Avatar for Shaitan00

What would your rule be for definingen when a token/line is invalid? I would check the the number of tokens in each class is first 2, then 8 Or do you want a more elaborate check?

Member Avatar for jencas
0
190
Member Avatar for monkey_king

Hi, given a cstring, I need to extract the digits in it, the digits are prefixed with either a '+' or '-'. Like [CODE] ,.,.,.,+3ACT,.,.,.,.-12,.,.,.,.,.,.,.,actgncgt #OUTPUT 3 12 [/CODE] I've made a working program that does what I want, but it seems overly complicated. Does anyone have an idea if …

Member Avatar for Yrth
0
148
Member Avatar for slawted
Member Avatar for anirbanjoy

It's shouldn't be necessary to use extern, generally you have access to all the public variables and function in the symboltable, but only the externed are required to have the same signature, from version to version. This is atleast how it should be. [url]http://people.redhat.com/drepper/dsohowto.pdf[/url] try doing a ldd on your …

Member Avatar for anirbanjoy
0
375
Member Avatar for vishalonne

[QUOTE=Sky Diploma;892739] Firstly I see that you are Using a outdated compiler. Though it is not il-legal to use it . It is considered better if you use a modern compiler like CODE::BLOCKs etc.[/QUOTE] I normally wont go into small errors in other peoples posting, but it should be noted …

Member Avatar for monkey_king
0
200
Member Avatar for george_cpp

I think it depends on what you are doing with the file. I've found that the FILE, strtok is by far the fastest way of reading in data. I've been using flat files, (same number of columns in all lines). On the scale of several gigabytes. And avoiding the c++ …

Member Avatar for monkey_king
0
5K
Member Avatar for monkey_king

Hi I'm having a very basic newbie problem, The compiler forces me to do a strdup (because of cons correctness), can I void the extra line in my code, and then I cant seem to update my array after the funciton call [CODE=c++] void fix_name(char *name){ if(name[strlen(name)-1]!='/'){ char *tmp = …

Member Avatar for monkey_king
0
186
Member Avatar for kostasxx

[QUOTE=articlemaster9;879657]c is generally slow compared to other programming language. Gone through your coding and nothing seems wrong. [/QUOTE] Just out of curiosity, what languages should be faster? Assembler, fortran?

Member Avatar for vs.vaidyanathan
0
197
Member Avatar for monkey_king

Hi, can anyone tell me why i can't clean up the memory, and maybe a small solution. I'm allocing memory with strdup for each key, but I cant figure out how to erase the key with free. Before anyone starts talking about mixing c++ and c, I know it's generally …

Member Avatar for ArkM
0
2K
Member Avatar for monkey_king

Hi, [LIST=1] [*]Question Why does valgrind complain? [CODE] Conditional jump or move depends on uninitialised value(s) ==25636== at 0x4C26D29: strlen (mc_replace_strmem.c:242) ==25636== by 0x40060A: main (test.c:7) [/CODE] [*]Question Strlen doesnt apparantly tell you how much space you have in your array, but the number of chars til '\0'. I my …

Member Avatar for fpmurphy
0
241
Member Avatar for monkey_king

Hi I stumpled upon some c-code, which syntactically is different from what I've seen before. [LIST=1] [*]first [CODE=c] void strreverse(char* begin, char* end) { char aux; while(end>begin) aux=*end, *end--=*begin, *begin++=aux; } [/CODE] Would this be the same as [CODE=c] void strreverse(char* begin, char* end) { char aux; while(end>begin){ aux=*end; *end--=*begin; …

Member Avatar for monkey_king
0
213
Member Avatar for Massena

It's in the nature of finite precision. Theres not much you can do about it. there a basicly two kinds of datatypes. 1. integral 2. float integral being, int, char, byte etc floats being, float, double integral is always precise, floating values are more obscure What numerical libraries do is …

Member Avatar for ArkM
0
119