Posts
 
Reputation
Joined
Last Seen
Ranked #592
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
~51.3K People Reached
Favorite Tags

98 Posted Topics

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
983
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
250
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
251
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
125
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
144
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
136
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
147
Member Avatar for marirs07

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

Member Avatar for restrictment
-2
76
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
113
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
480
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
482
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
191
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
150
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
378
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
207
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
188
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
200
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
245
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
215
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
121
Member Avatar for K'rul

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.

Member Avatar for szcfama
0
240
Member Avatar for anujsharma

[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?

Member Avatar for BestJewSinceJC
0
116
Member Avatar for vasek

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 …

Member Avatar for homeryansta
1
131
Member Avatar for Duki

Write an example on datainput, and dataoutput, like int inPut=1234; char *output= \\how do I convert 1234 to char*

Member Avatar for tux4life
0
249
Member Avatar for azjherben
Member Avatar for 1obama

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]

Member Avatar for monkey_king
0
80
Member Avatar for cigur

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]

Member Avatar for tux4life
0
116
Member Avatar for monkey_king

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 …

Member Avatar for monkey_king
0
131
Member Avatar for newcook88

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.

Member Avatar for newcook88
0
163
Member Avatar for mimis

[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 …

Member Avatar for tux4life
0
251
Member Avatar for lehe

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 …

Member Avatar for VernonDozier
0
93
Member Avatar for FrancisC07

hehe, To the original poster. Maybe you should clarify a little, what it is that you want.

Member Avatar for Ancient Dragon
0
163
Member Avatar for IrishHenshin

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 …

Member Avatar for monkey_king
-1
142
Member Avatar for Zcool31

Without having lookin so closely at your code shouldnt child2->accessPtd() be instance->accessPtr() instead?

Member Avatar for Zcool31
0
229
Member Avatar for neodregan

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

Member Avatar for monkey_king
0
220
Member Avatar for ARYT

Try cutting down your program to just a few lines, check the compile errors, fix those. Then you should understand what you did wrong.

Member Avatar for monkey_king
0
221
Member Avatar for Spanki
Member Avatar for Spanki
Member Avatar for monkey_king

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 …

Member Avatar for monkey_king
0
94
Member Avatar for krutthika

[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

Member Avatar for monkey_king
0
101

The End.