- 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
98 Posted Topics
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 … | |
Re: I don't understand your problem. Doesn't the 500 line code work? Is it a design question? In a general context in c++, you never have to write a method that does the sorting. It's a good exercise though. | |
Re: [QUOTE=anujsharma;871873]no i went thru the link but i needed code just go thru my code [code=c] #include<unistd.h> int main() { int n2,n1; int randNum; int index; int lowest=10, highest=1000; for(index=0; index<5; index++) { randNum = (int)((highest-lowest)*rand()/(RAND_MAX + 1.0))+lowest; printf("%d\n",randNum); } return 0; } [/code][/QUOTE] So whats the problem? | |
Re: If you want to read in a matrix you need some considerations. First of all you need some cind of datastructure to have the data in some datatype. A int** would be very suitable. But you need to know the dimesions, you will get the number of columns after the … | |
Re: Write an example on datainput, and dataoutput, like int inPut=1234; char *output= \\how do I convert 1234 to char* | |
Re: I have no fucking idea what the question is | |
Re: I think this is an excellent example of why humans shouldnt use automated translation programs. Like babelfish and translate.google. I understand he wants to write a calculator that uses polish reversed notation. I don't know if he wants std array[] or stl style array [url]http://www.josuttis.com/cppcode/array.html[/url] | |
Re: I'm not an expert, but you should be able to do it. I think its called an aggregate class [url]http://en.wikipedia.org/wiki/C%2B%2B_structure#Aggregate_classes[/url] | |
I'm trying to get myself acquainted with memory allocation and deallocation while writing a program that will actually be usefull for me. The program is a simple datareader, that tries to read a matrix from file. The "main" program which works is 'int get_lex(char *in,char *delims,char ***returnvals)' This will essential … | |
Re: What is the ordering? If you want to sort by the most frequent elements first, then you can use the link given to you. If you are sorting by some other rule, you should say what rule that is. | |
Re: [QUOTE=mimis;835775]I can't tell you any special problem because there are lots. But i ask you how to represent big integers and how to to do operations in general.[/QUOTE] What exactly do you want, your question is to general. If you want to represent a arbitrary integer, you could use a … | |
Re: when you use new the argument it takes is a size_t normally everyone is simply using an int since this is enough for most purposes. the type of size_t is implementation specific, on my computer its a unsigned long int This means that on my system If I have a … | |
Re: hehe, To the original poster. Maybe you should clarify a little, what it is that you want. | |
Re: You should start by defining the problem itself. First aff all assume you will only be using ascii symbol. This way you will only be needing to keep track of 128 diffent kind of charachters. Make an int array 128 long, initilaize to zero for entire entries Make a good … | |
Re: Without having lookin so closely at your code shouldnt child2->accessPtd() be instance->accessPtr() instead? | |
Re: HI, a huffman tree is essentially a funky binary tree. So you can use all the tricks from the binary tree. Check wiki [url]http://en.wikipedia.org/wiki/Tree_traversal[/url] I think you should be looking into the preorder traversel good luck | |
Re: Try cutting down your program to just a few lines, check the compile errors, fix those. Then you should understand what you did wrong. | |
Re: Post your compile errors, and I'll have a look at it. | |
Re: why dont you atleast try before wasting bandwidth | |
Hi, I'm considering using some boost stuff for my next project. But it's quite essential, that the program can be ported to multiple platforms with different setups. I've always used -ansi -pedantic -Wall And so far the projects has been working on sun/gnu/intel compilers, on both windows and linux. But … | |
Re: [QUOTE=Ancient Dragon;827074]did you [URL="http://lmgtfy.com/?q=C+program+for+audio+compression+and+decompression%3F"]try this?[/URL][/QUOTE] lol, got to remember this one |
The End.