- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 2
- Posts with Upvotes
- 2
- Upvoting Members
- 1
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
#include<stdio.h>
int main(void)
{
printf("No words can describe me ..... ");
main();
return 0;
}
- Interests
- Sleeping, Googling
- PC Specs
- P4, 2.8 GHz, 512 MB RAM
38 Posted Topics
Re: The address of a local variable cannot be returned from a function. I think the problem is with the function [COLOR=blue]char* subArr(char array[65535], int length)[/COLOR] At the end of this function you are returning "temp" which is the starting address of the array temp which is created in this function. … | |
Re: A slight modification for the bin2dec function. Removes the nested for loop. Reduces the overhead and removes the temporary variable 'm'. [CODE] int bin2dec(char *bin) { int b , k, n; int len, sum = 0; len = strlen(bin) - 1; for(k = 0; k <= len; k++) { b … | |
Re: This is one way of going about it without much thinking fn = [ Phi^ n - (-Phi)^-n ] / (2Phi-1) for smaller values of n you need approximation. Phi = ( 5^½ + 1 ) / 2 = 1.6180339 (the golden ratio) ^ = power But this method is … | |
Hi all, Can anybody tell me how to calculate the order of a recursive function. Lets take factorial function. Without using recursion [COLOR=blue]int x =1;[/COLOR] [COLOR=blue]for(int i = 1;i<=n;i++)[/COLOR] [COLOR=blue] x = x*i;[/COLOR] In this case the order will the O(n) in terms of time and in terms of space … | |
Re: Hi , I compiled the program in VC and didnt got any error. Its working fine. Only one warning. Thts beacuse u have declared main as "int main (void)" and the main was not returning anything. Just add one "return 0" and the warning will vanish. | |
Hi all, Can anybody help me with a an algorithm to find the maximum subset sum in an array. It would be better if the solution is of O(n). [example: {5,-2,10,-4} the maximum is 5 + (-2) + 10 => 13]. | |
I have executed the below programm on both C and C++ compiler and got different results [CODE]#include <stdio.h> int main() { const int a=10; int *p=(int*)(&a); *p = 20; printf("address of a=%u\t%d\n", &a,a); printf("address of p=%u\t%d\n", p,*p); return 0; } [/CODE] With C compiler I got the output address of … | |
Hi All, Can we delete this pointer from a member function. I have written three programs to try this. The first two crashes at run time while the third doesn't. Can somebody explain me this????? 1) This crashes at run time. [CODE]#include <iostream> using namespace std; class Base { public: … | |
Why cant we have a virtual constructor? All the materials give somewhat similar anwer to this question. "First the VPTR Pointer is initialised to it's proper VTABLE by the contructor which is automatically done by the compiler ,,,," or "You don’t ever want to be able to make a call … | |
| |
[code]#include <stdio.h> #define a b #define b a int main(void) { int a = 20, b = 30; printf("%d %d", a, b); } [/code] What will be the output of this programm ?????????????? Really confused with this ... Can somebody tell me what exactly will be happen and how macros … | |
Re: Which compiler are you using??? | |
Re: You should put [CODE]equihrs=equihrs-12;[/CODE] inside this if also [CODE]if(equihrs==12)[/CODE] Other than that I dont see any problems | |
Re: Can you explain the problem????? | |
Re: "If a character is a string, change it to an underscore" I guess Dave meant "If a character is a space, change it to an underscore" | |
I have to write a function which takes an integer array as input and it should return true if the array contains 1,2,3 or 4. Conditions 1) The function should pass thru array only once. 2) Can use two local variable. 3) Preferably using bit manipulation. Now suppose if the … | |
Re: I hevent gone thru your code ... You can do something like this Random Number % Number chosen == 0 then proceed else choose other random number. | |
Re: Modify your MarkNumber as shown below. [CODE]void MarkNumber(int input) { int loop=input ; while (loop >= 10) { cout<<"0123456789"; loop -= 10; } int n = input%10; for(int k = 0;k<n;k++) cout<<k; cout<<endl<<endl; }[/CODE] | |
Re: I tried running the same code but didnt got any segmentation fault. Just changed the prototype of main and try it | |
Re: [code]void stackLL::push(int value) { Node *temp= new Node; temp->data=value; temp->link=top; top=temp; [COLOR=blue]delete temp;[/COLOR] } [/code] Why are you deleting the memory pointed by temp? top is also pointing to the same location. I think that is causing the problem. I commented that part and compiled. It didnt crash. | |
[code]#include <iostream> using namespace std; class Exercise { public: int a; Exercise(){cout<<"constructor\n";} Exercise(const Exercise& x) { cout<<"copy constructor\n"; a = x.a; } Exercise& operator= (Exercise &x) { a = x.a; cout<<"assignment operaor\n"; return *this; } }; Exercise fun(Exercise& ); int main(void) { Exercise y; Exercise z; z = fun(y); return … | |
[CODE]void main(void) { char *p = "name"; p[0] = 's'; printf("%s", p); }[/CODE] The above piece [COLOR=black]of code is giving me eror at run time. The reason for this error might be that I am not allocating any memory for the pointer(correct me if I am wrong).[/COLOR] [COLOR=black]My doubt is, … | |
Re: You have to sort the array with a O(n) sorting technique. Then search for the duplicated elements . (if nth and (n+1)th elements are same they are duplicated). Delete the elements and copy all the element after it one element backwards. But I think order will increase from n. (not … | |
Hi all, What is the effficient way to check whether a single linked list is looped somewhere.The number of nodes in the list is not known. In that case traversal of SLL will go into an infinite loop. One solution I have is to store each address of node in … | |
Re: [code]#include <stdio.h> #include <string.h> int main() { char a[100]; int len, i; printf("Enter the string"); scanf("%s", a); len = strlen(a); for(i=0;i<len;i++) { if((a[i] <= 'm')&&(a[i] >= 'a')) { a[i] = a[i] + 13; } else if((a[i] > 'm')&&(a[i] <= 'z')) { a[i] = a[i] - 13; } } printf("%s", a); … | |
Re: 1. For upadting "r+" can be used. 2. What should be the last character of ur string or how u want ur string to terminate ? | |
Re: Is there any other way (I mean using bitwise operators) ??? | |
Re: Y dont u search in web. U can get tons of material related to inheritance. Just give the string "Inheritance tutorials"(google) | |
Hi all, I created a string object and printed its size. Its always priniting output as 16. Why is it like that? Can anyone give me idea about how string class is implemented. I am using VC [COLOR=blue]string input; cin>>input; cout<<sizeof(input)<<input<<'\n';[/COLOR] | |
Re: Try this. #include <iostream> #include <string> using namespace std; This should remove the error in first line and "//getline (cin, input); // Error Given: " 'getline': identifier not found " I dont think functioin get is declared in string or iostream. Thats y its giving undeclared identifier error. | |
Re: During the first choice how will the file contains data???? The file will not be created at all ... | |
Re: What is final_seek_pos??? [COLOR=royalblue]#include <stdio.h>[/COLOR] [COLOR=royalblue]void main() { FILE *fp; char update_record[40] = "STEPHEN"; fp = fopen("test.txt", "rb+" );[/COLOR] [COLOR=royalblue] fseek(fp, 0, SEEK_SET ); fwrite(update_record, sizeof(update_record),1 ,fp );[/COLOR] [COLOR=royalblue] fclose(fp); }[/COLOR] [COLOR=#4169e1][/COLOR] [COLOR=#4169e1]This code is printing STEPHEN for me.[/COLOR] | |
Re: Use [COLOR=blue]return 0;[/COLOR] at the end of the program, otherwise compiler will throw warning. Its a good programming practice. | |
Re: This is one way of doing it (not so efficient). I am not quite familiar with printf. I believe using printf efficiently the two nested for loops can be removed. Refer some books in C for the usage of printf statement. [CODE]#include <stdio.h> int main() { int i, k, n= … | |
Hi, I am bit confused with the concept of pointer to a data member of a class. In the below program what actually will the pointer variable be storing? When i tried printing the value of address I got value 1, Whatt does it mean? [COLOR=blue]class A{ public: int d; … | |
Hi Everybody, Myself Dilip over 24 years of age from India, Kerala (Gods own country - atleast some of u might be knowing). Currently working as Software Engineer in Honeywell Tech Sol Lab - India. Topics of intereset - C and Operating Systems. Best Wishes, Dilip Mathews. |
The End.