518 Posted Topics
Re: >destructor will probably not be called Yes, It will not be called >what happens to the memory allocated for str? It will be released by the compiler as soon the object of [B]Sample[/B] gets out of scope >Would this result in a memory leak? No. Remark: The compiler assures that … | |
Re: >Can somebody simply the function for me plz. You mean explaining it? | |
Re: Please be specific. No one has time to look at your 1MB code and point out the error. | |
Re: Keep it simple. You should perhaps say that you want to write a parser. I guess you already have made the [B]stack[/B] class. At any point of time the comparison operator works with characters too. | |
Re: The error is definitely right. You are using uninitialized [I]d[/I] and [I]c[/I]. So what to do? Look at the defination of [CODE]AltMoney read_money() { [B] [COLOR="Red"] int d, c;[/COLOR][/B] cout << "Enter dollar \n"; cin >> d; cout << "Enter cents \n"; cin >> c; blah blah }[/CODE] I think … | |
Re: >can't quite figure out how to get the queue to appear on screen. [B]Complete the queue::print() function.[/B] First of all, make print() a member function of the class. In the print () function, you should simply print your main data array which is. int a[SIZE]; from front to rear with … | |
Re: The code tags are [[B]CODE=c++[/B]][[B]/CODE[/B]]. You are getting the error because you are redefining myfile at two places: first as ifstream and then as ofstream which is illegal. use fstream instead as: [CODE] fstream myfile; myfile.open(filename); [/CODE] As I can see, your array is of type double. getline() works only … | |
Re: There is a much better way: Just add a [icode]i--[/icode] in the body of the if statement; [code=c++] for (int i = 0; i < inp.length(); i++) { if (inp[i] == '~') { inp.erase(i, 1); i--; } } [/code] And it works like charm. I dont know why are you … | |
Re: You can use system() function and issue a copy command. I don't know what are the alternative. But this will definitively work. | |
Re: You have any idea what are you asking? We don't know you, nor your ability, nor that how much time you have, not how much brains you have. We know nothing of you then how can we tell what is a "mini" project for you. Mini can be a Hello … | |
Re: Well well, I guess the "My fav IDE/Compiler war" stared again!! >Code::Blocks is too heavy I meant that it has too much options I don't use I have a simple reply.....Don't use the "much options". Code::Block appears great to me. On both Linux and Windows. I have heard very (surprisingly) … | |
Re: When a file is opened is in Text Mode, the operating system's new-line character is auto-magically converted to the standard '\n'. >Not sure what MAC uses. BTW Mac uses "\r". "On unix systems, the standard end of line character is line feed ('\n')." source: [url]https://developer.mozilla.org/En/C___Portability_Guide[/url] | |
Re: Although Salem had clear it up all, but maybe for a reference you can read :[url]http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.11[/url] | |
Re: Class String; the "C" of class is capital. Well, anyways, I really don't know what does ensureSize() do (please provide its defination) I also don't know about >> [code] os << "S(" << temp.m_length << "," << temp.m_bufSize << ")[" << temp.m_buffer << "]"; [/code] Explain me why did you … | |
Re: If you are a learner and still in basic stage, I prefer you write your own class about Date and overload the comparison operator, and then work with them. | |
Re: Read here about Constructor :[url]http://www.parashift.com/c++-faq-lite/ctors.html[/url] | |
Re: >Help me!!!! about operator overloading It doesn't work like this. You should be more specific about what you want to ask. First of all read this link -> [url]http://www.parashift.com/c++-faq-lite/operator-overloading.html[/url] and come back. BTW a short answer to why we use operator overloading is so that our class have a intuitive … | |
Re: Why the heck you are using cstrings. They are old, they are evil and they can lead you in trouble. Use std::string and be happy in life. | |
Re: Point 1: n*(n+1)/2 is even valid for n=1, so you don't need a degenerate case of n=1. Point 2: as vmanes said, your base case is good, but look at your recursive case: [ICODE]return (n+sum(n+1))[/ICODE] Try to think what would happen if I call sum(2)? it would return 2+sum(2+1) which … | |
Re: [QUOTE=tux4life;813512] Hope this helps...[/QUOTE] Yeah, it will surely help him. He will copy-paste the code and will forget where he committed mistake.:angry: Did you tried explaining him where he went wrong Please note: I know no one gets paid to help here. I even know that you can debug the … | |
Re: Create a static member in your class which is a bool type 2D array (call it say,[B]current_pos[/B]) of 8X8 elements. Each time you assign a Position to the object, be sure to mark the current_pos[x][y]=TRUE; So, now you can keep track of what all postition are been ocupied. Hence, as … | |
Re: [ICODE]if (gmOption == 1)[/ICODE] change it to '1' not 1 since gmOption is a char not a int. [CODE]cin >> cheat; if (cheat == 236)[/CODE] I think the cheat is 236 right? So it should be a string. Define your cheat as[ICODE] char cheat[3[/ICODE]] and not simply as a char … | |
Re: I have little bit modified your code and it is working. The only drawback is that it cannot handle more than one digit nos. at any point of time during calculation. I have commented the code and am sure that you will understand it. Though, I will explain it completely … | |
Re: We only give homework help to those who show effort [url]http://www.daniweb.com/forums/announcement8-2.html[/url] Show efforts=get help | |
Re: What a crap this code is...........? And you say you just want it to compile.!! Read your text book first. | |
Re: Wow, a zig-zag flow of control. But is definitely not a wow. Sit down with a pencil-paper and design a flow chart of your program. The flow of program is not efficient. main calls read/write which calls haha which can in turn call read/write and so on. This is definitely … | |
Re: n^3 + (3n^2+2^n+1)^3 + (3n^3+3n^2+2^n)^3 = (3n^3+3n^2+2^n+1)^3 In the above equation, put different value of n=1,2,3,4,...... and you get the quadruplets. BUT remember that this was a short-cut which I gave you. You should know how this was derived. Currently I don't have enough time to explain it. Read:[url]http://www.geocities.com/titus_piezas/RamCube.htm[/url] for … | |
Re: Please search the thread's before: [url]http://www.daniweb.com/forums/post814395.html[/url] <<here you may find something useful. | |
Re: Look at your for loop. Mathematics says that you just need to check it till [B]i<=sqrt(n) [/B]i.e. the square root of n. That is, it your input number is 33, then just check that if should not be divisible by any number from 2 to sqrt(33) which is 5. So … | |
![]() | Re: >Yeah I know, this instanciation + use of Printer here looks definitely dodgy. You are using dynamic memory management using [B]new[/B]. Be sure to free the memory with [B]delete[/B]. >Why do I get these errors? These are the Linking error you are getting. Its probable that you are not including … ![]() |
Re: [QUOTE][code] // print output ofstream fout; fout.open("aboutYou.txt", ios::app); fout << endl; fout << age << endl; fout << gpa << endl; fout << name << endl; fout << gender << endl;[/code][/QUOTE] You told me that output should go to the screen, right? Then just tell me why are you outputting … | |
Re: You got this code from a C++ Teacher? LOL Does'nt look like Anyways, I prefer you should first read about files and streams rather than geting a readymade answer. I can answer you thingy, I cam remake your whole code also, but then there is no point in doing it … | |
Re: This is the Error I get when running your program on g++ with -Wall flag on,phillipdaw is: [icode]ISO C++ forbids taking address of function ‘::main’[/icode] So, I guess that answered all the doubts regarding calling of [B]main()[/B]. So the rule of thumb: NEVER CALL MAIN() Rather than exit(0), you can … | |
Re: [icode]#include<conio.h>[/icode]? conio.h is not standard header. Don't include it. Why do you need it? | |
Re: [QUOTE=jitendra.theta;812147] what i have read that ++c or c++ returns a value which can't be again incremented or decremented (like 5++). .[/QUOTE] You have read wrong. You are though right by saying both of these operator returns a vale, but the pre-fix(++x) return that value by reference. That means it … | |
Re: [QUOTE=daviddoria;811883]I've never done this, but it doesn't look you passed any arguments [/QUOTE] You are right. he has just called the program without any command line argument. Also, you answered it rightly to him. As a matter of explanation: the system() function takes a Cstring and pass it to the … | |
Re: You are actually doing crime here but letting the compiler generate the copy constructor and the assignment operator, Look closely what [ICODE]Inst = A(4);[/ICODE] do(sorry Comatose, I am answering that): On the right side of the assignment operator, a temporary object is created, a copy constructor is called which copy … | |
Re: [QUOTE=Lotus_2011;813447]How to get information about big nums can you help me with searching... thanks in advance ...[/QUOTE] Atleast try searching. Google is your friend. BTW, you can start somewhere here: [url]http://www.google.co.in/search?q=implementation+of+big+numbers+in+c%2B%2B[/url] [url]http://www.daniweb.com/forums/newpostinthread176976.html[/url] [url]http://ittb.pcriot.com/forum/viewtopic.php?t=23[/url] | |
Re: I remember I once made a similar code. You can study that and see if it makes any benefit to you. If any query regarding the code ask back. [B]The N Digit Calculator [/B] [url]http://ittb.pcriot.com/forum/viewtopic.php?t=23[/url] | |
Re: A quick point to note is that g++(and other compiler that support c99) allow VLA(Variable Length Arrays), if which you can specify a variable as the length of the array. i.e. the following statement are valid [code] int a,b; cin>>a>>b; int arr[a][b]; [/code] But then, the C99 standards are not … | |
Re: [code]int main() { Coord a;//this thing is the trouble maker [/code] Do you realize that you want to create object without giving any parameter. This was good if you had defined a no-argument constructor. Although, there was no need for a no-argument constructor as the compiler generates auto-magically for you … | |
Re: [code]file.open("book.txt", ios::app);[/code] Do you see that ios:app? It is telling the compiler to append whatever to book.txt So, if you want to start afresh, just remover that ios::app tag Use [code]file.open("book.txt",ios::trunc);[/code] or you can even simply use [code]file.open("book.txt");[/code] | |
Re: Did you google them? I mean, I would have to type a long essay about them. Read:[url]http://cplus.about.com/od/learning1/ss/clessontwo_7.htm[/url] [url]http://www.linuxtopia.org/online_books/programming_books/c++_practical_programming/c++_practical_programming_077.html[/url] | |
Re: I agree with, VernonDozier. cin>> is already overloaded for you to input the right thing. cin.get is a unformated input function. It does not format the input accordingly. It is just used for char heres the prototype [code]get ( char* s, streamsize n );[/code] | |
Re: Dude, #'s are [B]Pre[/B]processor directives. That means all of those things are done before compiling your code. So here how it goes. First, the preprocessor work on all the #'s and make the code ready for compilation it doesnt even see your code. nor does the preprocessor knows c/c++. It … | |
Re: First follow the Ancient Dragon comment. then parse the whole string by checking each letter, run a for loop. I dont know if your using c++ string or cstrings. I am explaining using cstring [code] char str[MAX]; cin.getline(str,MAX); int len=strlen(str); for(int i;i<len-1;i++)//run till lenght -1 { if(str[i]=' ') toupper(str[i+1]); } … | |
Re: Mate you dont need gotoxy(). Neither it is standard nor it is needed. I'll give you a hint which is already posted, use white space. It means to place required number of spaces (' ') before printing the characters : [code] ______# _____### ____##### ___####### __######### [/code] here the underscore … | |
Re: line 20!! shouldnt that be in a loop? and why do you use so many useless variables(d,e,f,g,h). Just say d=(n*(n+1))/2 sum2=pow(d,2)//squaring d | |
Re: What I am guessing is that you dont have the source of of the .obj(or .o) file. Don't worry. If you know what all prototypes where there in the source file, you can create a header file which have all the prototypes and then compile it. It will compile easily. … |
The End.