238 Posted Topics
Re: the buffer is not allocated with sufficient memory. | |
Re: line #224: U are getting the max node in the temp variable. But u have not put it in the particular location. No links assigned. !!!!!!!!! * Instead of deleting the cur node, copy the maxnode data into cur node and delete the max node. There may somemore error I … | |
Re: 1> read an item 2> start from the begining of your list: if(new item > curent node item) move to next node else break 3> create a new node with the new data 4> put the new node in the current location.: *** for this u have to keep the … | |
Re: in class AVLTree: You are not initializing root. Add a constructor and initialize the root with NULL in there. [CODE] AVLTree() { root = NULL; } [/CODE] | |
Re: that is not a way how u should proceed declaring so many variables with similar meaning. This is where people uses array. Use a 2D float array to store your scores. Use another array for storing the averages. e.g. [CODE] float judge_score[5][5]; float judge_avg[5]; [/CODE] | |
Re: add the default constuctor in Carbol class. Check the line: [CODE] Carbol2 ubjuct; [/CODE] when u do this it invokes the default constructor of Carbol2 which is [B]Carbol2::Carbol2()[/B] and also the default constructor to the base class is invoked which does not exist. You have to write the default constructor … | |
Re: U are making a shallow copy for Message while assigning it to the data. U need to do a deep copy instead to retain the member data. Overload the assignment operator for Message class and use strcpy() in it for copying each of the member. There may be some more … | |
Re: include [B]stdbool.h[/B] The type is "bool" e.g. [CODE] #include<stdbool.h> bool b= true; [/CODE] this works in my compiler(cc). | |
Re: its because in line #7 u are reading using scanf() and its looking for an int as input. When u enter a non-digit character it doesn't get what it is expecting hence it won't set the value to the variable num. Try giving a character in the very first time … | |
Re: line #23: it should be [CODE] cout<<data[(i*cols)+j]<<" ";/*not i*rows*/ [/CODE] | |
Re: [B]tower of hanoi [/B]is a very good example for solving by recusrion. Though recusrion is helpful at times while solving some very critical problems though it has some demerits. Read about recursion in more detail to know its merit and demerits. | |
Re: when accesing at an index say kind.at(n) just make sure that n>=0 and n<kind.size() e.g. check in lines 85, 87, 88, 91, 118. I didn't checked it completely, do it yourself. | |
Re: everywhere u are accesing the members of some structure using pointer and there doesn't seem to be any check for NULL statemnt. | |
Re: 1> use code tag 2> in function square_array() and cube_array() u are modifying the original array loosing the original values. | |
Re: [code] int main() { int two_d[10][20]; return 0; } [/code] take it.... or else tell us what problem u are facing with 2d array..... | |
Re: > line #4:Start using int main() instead of void main(). > line #25: when u reach the end, say i=3 and length of string is 4, u are accessing the (i+1)th element that is arr[4] which does not exist because your string ends at index 3. Try to correct it. … | |
Re: u must intialize a static member. Add the line [CODE] int Counter::count = 0; [/CODE] before main() or other module where u are using or just after declaring your class. A static data member must always be initialized before being used. | |
Re: line #38: u are not using strtok() in the way u should. If u want to continue to get the next token then u must pass NULL in the 1st argument to strtok() after making the first call to it with the actual string. its like: [CODE] char *tok = … | |
Re: that is called the arrow operator which is used to access the members of a class or a struct using a pointer. Check the link [url]http://iqsoft.co.in/cpa/notes-cpp/structs/arrow.html[/url] | |
Re: I still doubt your logic for solving a sudoku. Anyways what the checkDigit() method doing? And will u explain your logic in summary (not in codes just the summary such a pseudocode with minimum complexity). | |
Re: the loop for bubble sort is [CODE] void bubleSort(int data[], int size) { for(i=0; i<size-1; i++) { for(j=0; j<size-i-1; j++) { if(data[j] < data[j+1]) swap(&data[j], &data[j+1]); /*assuming swap function is there*/ } } } [/CODE] | |
Re: why have u written the code from line #22 to line #26. Do u think u need them.....? | |
Re: u need a heapsort.cpp file for creating heapsort.o U are not giving input to the g++ command in line #13 in the Makefile. If u have only a heapsort.h file where the whole thing is defined and u have included this file from driver.cpp then u can simply remove the … | |
Re: the function fun() takes a funtion(whose return type is int and with no params) pointer as its argument. And u are sending [B]main[/B] to that funcion. Thats it. Read on pointer to function. | |
Re: check links: [url]http://www.linuxforums.org/forum/linux-programming-scripting/26306-reading-directory-contents-files-c.html[/url] [url]http://www.linuxquestions.org/questions/programming-9/c-list-files-in-directory-379323/[/url] | |
Re: ofcourse it wil crash because it is getting into an infinite loop because its not reaching the final condition. make your condition from [B]if(n==0)[/B] to [B]if(n<1)[/B] in the factorial function | |
Re: [QUOTE=seo2005;1033857] Suppose I enter 321 y will become 32 z will become 1 x will be 32 It will print first z which is 1 then it will print x which is 32 But it should have been 123 ( Reverse of 321) [/QUOTE] why wil it print 32. See … | |
Re: check the prototype of the function [B]reverseArray()[/B] | |
Re: yes you can try something like this [code] bool isAWin(char &winner) { if(isWin('O')) /*considering your players as X and O (change to whatever u are using)*/ { winner = 'O'; return true; } if(isWin('X')) { winner = 'X'; return true; } winner = ' '; return false; } bool isWin(char … | |
| |
Re: what is the reason that made u feel that the statements [CODE] for(n=i+1;n<size1;n++) [/CODE] and [CODE] for(n=1;n<size1;n++) [/CODE] are equivalent. How does 1 and i+1 becomes same. That is the logic and u are changing the whole logic for sorting. | |
Re: google for IPC. U wil get a hell lot stuff. | |
Re: line #57 and #59. using = instead of == fom comparing also couldn't get these lines [CODE] if(balls[i] = 10) //use == { if(balls[i] = 10) //use == /////////////////////////// [/CODE] why the second condition when u already did it...... | |
Re: may be u can display using cout as [CODE] string str; char *buf = (char *)&str; /*u need to know the size of 'str'*/ /*sizeof(str) might work but m not sure about it*/ int i; for(i=0;i<sizeof(str);i++)/*considering sizeof() works*/ cout<<(unsigned short)*(buf+i)<<","; [/CODE] I dont know any feature in KDev for displaying … | |
Re: The error message is clear enough. U are defining the function [B]void PlaceYourBet()[/B] more than once. Check your code. | |
Re: [QUOTE=miskeen;1035838]But, is there any proposed solution to what I'm looking for?[/QUOTE] use if() statement and strcmp() function for your purpose. | |
Re: 1> finding the mid: Your function for finding the mid element is good enough. The complexity is O(n/2) not O(n) but anyway O(n/2) is also considered O(n) only when n is very large. 2> mid of even set of data Its upto you or upto the requirement which will tell … | |
Re: I dont think u can do that. Its because the console is just a resource and the same resource cannot be shared by more than one process at a time. When u are doing a read operation the console is reserved for that process and any write operation will only … | |
Re: May be u can get some hint from this thread. [url]http://www.daniweb.com/forums/thread33551.html[/url] Many of the machine info u can get from the files present in the following folder: [B]/proc/sys/kernel[/B] | |
Re: Ofcourse there are generic ways to make a recursive method non-recursive. Just google for it. U wil get that. Regarding the use of recursive functions: It is not recommended always because it may lead to stack-overflow and crash of your program if the iterations are large in numbers. But its … | |
Re: the param to a switch cannot be a string. It can only be an integer. To achieve what u are trying use if-else statement alongwith strcmp(). | |
Re: Thank god there are only 26 alphabets. If there were 100 u would need to write 100 if statements. May be u can take some other approach for your problem such as: write a function like [CODE] void removeDuplicate(char *str); [/CODE] It doesn't necessary that a user wil input a-z. … | |
Re: use code tag. Do proper indentation to you code. | |
Re: its says the character 'a'. Like we represent a string using double quote, e.g. "test string", we represent a character using single quote, e.g. 'a'. | |
Re: [CODE] for(unsigned i = 0; i < cantidad_frases; i++) { for(; *frases[i]; frases[i]++) { *frases[i] = getchar(); } } [/CODE] U have not assigned memory to frases[i]. Do [CODE] #define MAX_STR 40 // whatever u want frases[i] = malloc(MAX_STR); [/CODE] U are alos doing another mistake: [CODE] for(; *frases[i]; frases[i]++) … | |
Re: [CODE] void f(int** a) //its a pointer to a pointer. The argument to the function f is a pointer to pointer { cout << **a; //prints the value stored in a, output is 45 cout << *a; //address of the memory where 45 is stored cout << &a; //address of … | |
Re: Hi, I compiled that file (client) and I am not getting any error . !!!!!! I used cc compiler and compiled on the following OS [CODE] Linux mymachine 2.4.20-28.9.XFS1.3.1smp #1 SMP Mon Jan 5 13:20:15 CST 2004 i686 athlon i386 GNU/Linux [/CODE] | |
Re: u are doing it in the correct direction. Go ahead with your code and test it. May be (not sure) u need to break up your file into smaller blocks for transferring if the file is very large. | |
Re: [QUOTE=Gribouillis;1030204] The function main in myprog will receive a char** argv containing the following strings [code] "-z", "hello", "-m", "this is a message" [/code] [/QUOTE] One small correction. char** argv will contain [code] "myprog", "-z", "hello", "-m", "this is a message" [/code] [QUOTE=Gribouillis;1030204] So there must be somewhere in a … | |
Re: [QUOTE=Bips123;1030240]Hi, I hav heard that it isn't that simple to write a program in linux using c. Lots of commands n stuff.Please simplify what actually I've got to do to run turbo c++ in my linux laptop as I am a beginner.[/QUOTE] I guess U will change your opinion once … |
The End.