75 Posted Topics
Re: you are using getch(), clrscr() all of which are part of <conio.h> which you haven't included. It is also suggested not to use <conio.h> as it is not standard and not supported in many compilers. You are returning 0 in line 272, but your main function's return type is void. … | |
Re: What do you actually intend to do? When I ran your code, for an input "abcde" I got an output "edcba". What is the problem you're finding with swap()? Just one piece of advice. Avoid writing codes like those in line 19 and 22. "++" operator may give different results … | |
Re: [CODE]b2 = &b1[0]; (b2+i)->iPageNo[/CODE] And no need of typedef | |
Re: If it's only for read only purpose, you can use your original string itself as an array of characters terminated with '\0'. [CODE] string myString = "hello world"; const char *myArray; myArray = myString.c_str(); [/CODE] Otherwise create a copy and do read/write [CODE] string myString = "hello world"; const char … | |
Re: check line 35. Syntax error. Also, I doubt int cardNumber is not initialized anywhere. | |
Re: [QUOTE=guccimane;1734038]I thought everytime I allocated memory using 'new', I am suppose to free the memory using 'delete'.[/QUOTE] You are right, but you try to use the memory allocated to the linked list after deleting it. This causes the problem. So do a delete only after you are finished playing with … | |
Re: [QUOTE=DarkPyros;1732403] the scanf at the end is to keep the program on the screen after it executes and displays the output..[/QUOTE] Use getch() function defined in conio.h thereby you can avoid using scanf() to hold the output screen. And before you proceed, you need to verify the sides belong to … | |
Re: To access element at a[5][4][9][20], use [CODE]printf("%d", *(*(*(*(a+5)+4)+9)+20));[/CODE] | |
Re: pls try this. [url]http://www.cprogramming.com/fod/putenv.html[/url] | |
Re: first of all if you intend to use a[] as a string, it should end with '\0' character. | |
Re: the function pow() returns double. So you can use double to hold the value. [CODE] using namespace std; int main() { double i; i = pow(2,1000); cout<<i<<endl; //prints 1.07151e+301 i = i*4; cout<<i<<endl; //prints 4.28603e+301 i = pow(i,((double)1/1002)); cout<<i<<endl; //prints 2 return 0; } [/CODE] | |
Re: assume the string is abcde first group "abc" and "de" separately "abc" is the fixed part and "de" is the variable part. keeping "abc" fixed, there are two possibilities with which you can arrange "de" [I]Iteration 1[/I] abc|de --- (1) abc|ed --- (2) In the next iteration, take out the … | |
Hi all, Sorry if this is a stupid question. Assume I have a code like this. [CODE] char *temp = "poiuytrewq"; std::cout<<*temp<<std::endl; //should print p function(temp); std::cout<<*temp<<std::endl; //should print i [/CODE] Basically my function() in the above snippet increments the pointer twice so that temp point to 'i' now. I … | |
Hi all, Here is a short summary of my piece of code. [code] double availableUnits = calculateAvailableUnits(some arguments); int minimumRequiredUnits = getMinimumRequiredUnits(some arguments); std::cout<<"minimumRequiredUnits = "<<minimumRequiredUnits<<std::endl; //prints 30 std::cout<<"availableUnits = "<<availableUnits<<std::endl; //prints 30 if (availableUnits < minimumRequiredUnits) { //throw exception; } //rest of the code [/code] Even though both variables … | |
Hi all, I'm trying to get an octal number from console and store it in an int variable using scanf. Here is my code. [CODE] int n; scanf("%i", &n); printf("\nEntered number in dec = %d", n); printf("\nEntered number in hex = %x", n); printf("\nEntered number in oct = %o", n); … | |
Re: You can use [CODE]Collections.sort(yourArrayList);[/CODE] But there is some work you need to do. You have to implement Comparable interface in your class. There will be a method called compareTo (Object o) which you need to override. Here you are free to code how you should sort (using first name or … | |
Here the value of int x is always zero. I don't know if there is any case where it is non-zero. If so pls reply. [CODE]int OperOverld::operator--(int x) { cout<<x<<endl; //always zero //some code goes here //... //... //... //atlast return some int }[/CODE] | |
Hi friends, I was understanding the concept of friend functions. I read in my book that there are two possible ways of "making friendship":cool: 1. Make a class a friend. 2. Make the method in a class a friend. I am able to write a code for the first point. … | |
Hi friends, One of my class member function is supposed to return an array of integers. Here's the function. [CODE]int* MyClass::getallVars() { int* a = new int; int b[] = { GetparentVar1(), GetparentVar2(), GetchildVar1(), GetchildVar2(), }; a=b; return a; }[/CODE] Is there anyway I can do this without the use … | |
Hi friends, I was trying out some inheritance related stuff and found something. I just want to know the reason why. I have a ParentClass and a ChildClass. Both have an integer named [B]commonVar1[/B]. Also both have a getter method of the same name. Here goes the code. [CODE]class ParentClassOT … | |
Hi friends, I know this is such a freak code, but out of curiosity I did it to see memory usage increase using new operator. [CODE]int main() { char* a; for (;;) { //cout<<&a<<endl; a = new char[10]; } }[/CODE] As you see line7 is commented. When i run this … | |
while i was learning about global variables I did some trials and found one problem. Here goes my code. [CODE]int cows = 10; //global variable void farm1() { int cows; cout<<"in farm1, cows="<<cows<<endl; cows++; } int main() { //cout<<"in main, cows="<<cows<<endl; farm1(); //cout<<"back in main, cows="<<cows<<endl; } [/CODE] Here line … | |
I'm trying something like this [CODE]void receiver (char* x) { cout<<x<<endl; //prints "a" cout<<*x<<endl; //prints "a" cout<<&x<<endl; //prints address of x } int main() { char p = 'a'; cout<<p<<endl; //prints "a" cout<<&p<<endl; //prints "a" receiver(&p); } [/CODE] In the main function for both p and &p, it is printing … | |
In C++ I'm able to do something like this [CODE](some_condition)? function1():function2();[/CODE] When i tried the same thing in Java it's not possible. It wants some variable to hold the result even though the return type of function1 and function2 are void. Is there any other way to do it other … | |
Here is my piece of code: [CODE] int b[2][2] = { {4,6}, {-3,0} }; int b_length = (sizeof b)/sizeof(int); int *sub_b = b[1];[/CODE] b_length will have the length of 2-D array b (4, in this case). now sub_b is the sub-array of b at row 1, which is {-3,0} Is … |
The End.