- Strength to Increase Rep
- +5
- Strength to Decrease Rep
- -1
- Upvotes Received
- 3
- Posts with Upvotes
- 3
- Upvoting Members
- 3
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
Re: 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] … | |
Re: 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 … | |
Re: 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. | |
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 … | |
Re: 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 | |
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, … | |
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> … | |
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 … | |
Re: 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 … | |
Re: I have no idea what you are asking. what do you mean by "running online" | |
Re: 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++ … | |
Re: 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++) … | |
Re: Just try to do the program, when its done, it should be clear what should be pointers. | |
Re: Hi omir People are normally quite friendly inhere, but you should ask a specific question. good luck | |
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); … | |
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 … | |
Re: 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? | |
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 … | |
Re: 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 … | |
Re: [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 … | |
Re: 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++ … | |
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 = … | |
Re: [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? | |
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 … | |
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 … | |
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; … | |
Re: 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 … |