2,712 Posted Topics
Re: I don't get it. What eludes people to think that we will use up our time to write a code for someone else without no compensation or without no effort on the other party. I am completely baffled by this type of attitude. | |
Re: Are you including other header file that has classes? If so then the class is probably missing a semicolon at the end of its definition. [code] class A { ... } ; <--- need semi-colon? [/code] If you do not have class defined in other header file, then something is … | |
Re: Because its inside the class definition. Technically, you can access a class data member , if you are trying to access it inside its definition. Think of class B like a member function accessing its private data, except its a class instead of a function. | |
Re: [QUOTE=esesili;957172]Thanks for helps. Can you tell me how can I fix it?[/QUOTE] [QUOTE=Dave Sinkula;957161][code]double avg_file(ifstream& source_file) { double number_in_file; double total = 0; int count = 0; [COLOR="Red"]while (source_file >> number_in_file)[/COLOR] { total = number_in_file + total; count ++; } //average of numbers in file return (count); }[/code] [url]http://www.daniweb.com/forums/post155265.html#post155265[/url][/QUOTE] Pay … | |
Re: 1) [URL="http://www.google.com/search?hl=en&q=sorting++c%2B%2B&aq=f&oq=&aqi=g4"]GOOGLE [/URL] it 2) use std::sort function. | |
Re: [QUOTE=gopi17;956668]okay, i understand...juz wanna ask...is it possible to create a huge array then minimize the array according to the users input... for example [CODE] game[500][500]; then minimize from there... [/CODE][/QUOTE] I think what you are looking for is [URL="http://reconnetworks.net/forum/index.php/topic,1569.0.html"]vector[/URL] or this [URL="http://www.cplusplus.com/reference/stl/vector/vector/"]vector[/URL] They have the capability of resizing to whatever … | |
| |
Re: Try cout.precision(25); | |
Re: This should be easy. [code] int cntr[256] = {0}: //counter for each character //read in char. //increment cntr for whatever you have read in while(iFile.get( c ) ) { c = ++c % 256; cntr[c] += 1; } [/code] There are still some caution to take, but this should be … | |
Re: Presumably, using non-temp value is faster. Think of whats going on. using temp : 1) Get the value from the user. 2) Copy that value to the address of temp. 3) Search for the value that resides in temp address 4) Copy that value and put it in the address … | |
Re: Lets see. Lets just take everything in this code to be related to heap_sort. [code] for(i= 32; i>1; i--) { SortHeap(arr, i - 1); } [/code] I substituted 32 for arr_num_items This is so far 31 iterations. Inside it, Lets see what sortHeap is. [code] for(o=root;o>=0;o--) { //removed for(i=root;i>=0;i--) {//removed … | |
Re: Its stupid : [code] #include<iostream> using std::cout; int main() { int a = 0; cout<<"#include<iostream>\n\nusing\tstd::cout;\n\nint main()\n{\n\tint\ta = 0;\n\n\n\treturn 0;\n}\n\n"; return 0; } [/code] | |
Re: How well do you know c++? for loops, do while, if else, class, ...? Also there is practice problem here. | |
Re: use stringstream. Convert string to numerics. To avoid all the integer hassle. | |
Re: What is the function .get()? Its not declared. [quote] bhn = b1.get(); [/quote] | |
Re: int getmarks(int marks[][3]); Note : You have to specify the column. Thats why the 3 is there. Although it could be any number. | |
Re: "void fun() throw();" That declaration tells compiler that this function , fun(), won't throw any exception. Similarly : void fun() throw(myException& m); Tells compiler and user that this function could throw a exception shown. | |
Re: I tried sooo hard to become a physic and see your source code, but no luck. Maybe it would be easier if you posted the code. | |
Re: Here is an idea, Make a program with one of the language you choose,make a scenario where a random number is generated for about 100,000 times, each random number generated represents a language you should learn in depth with. See which has the most hit, and viola. You got your … | |
Re: string.erase might be what you are looking for. | |
Re: Forget about that book. Read a more comprehensive book. I would suggest C++ Primer plus 5th edition. Its a little over 1000 pages long, all about C++ and its beautiful wonders. | |
Re: Damn Ancient Dragon beat me to it. Anyhow here it is : [code] #include <iostream> #include<fstream> using namespace std; int main() { fstream oFile("numbers.txt"); if(!oFile.is_open()) { cout<<"Error opening the file\n"; return 3; } oFile.seekg(0,std::ios::end); unsigned int size = oFile.tellg(); if(!size) cout<<"Empty File\n"; else { char c; while(oFile.get(c)) cout<<c; } } … | |
Re: I think you need to re think your design. Use for loops instead. Have a function that checks is a number is prime. Is it returns true then print that number. [code] for(int i = 0; i < MAX; i++) if( isPrime(i) ) cout << i <<" is prime : … | |
Re: [code] totalArea = (1/2) * PI * (radius*radius); [/code] what you are calculating is the area of a half of a circle. The area of a circle is pi* r^2 | |
Re: "The user enters: hhmmss " like this I assume : 074023 which is = 7:40:23 1) check if the 1st and 2nd number is <= 24 2) check if 3rd and 4th number is <= 60 3) check if 5th and 6th number is <= 60 if all return true, … | |
Re: Its because you open your file multiple times without reseting its position. Here is your program. I don't know if the output is correct, but it runs: [code] #include<iostream> #include<fstream> #include<cmath> using namespace std; double avg_file(ifstream& source_file) { double number_in_file; double total = 0; int count = 0; source_file >> … | |
Re: [QUOTE=NicAx64;954030]here if you want to make the changes without breaking the code now , make that x y and z mutable. dirty but it will help you not to break the code.[/QUOTE] why would you suggest that? Your just suggesting bad practice. | |
Re: From OP pdf file : [code] //Use the following code to check for file error if (input.fail()){ cerr<<"File not found!"<<endl; [COLOR="Red"] system("PAUSE");[/COLOR] return 0 [/code] | |
Re: For question # 1 (a) Is allocated with new or (b)just something like int a[1000000]; option a, use delete []. option b, its destructor is called, and deletes it automatically. But as Ancient dragon pointed out, there could be stack overflow. | |
Re: Just a wild guess. [U]CGUIEditBox [/U]C - c language? GUI - graphical user interface EditBox - edit box [U]CGUIFont[/U] C - c language ? GUI - graphical user interface Font - font [U]CXMLWriter [/U]C - c language ? XML - Extensible Markup Language Writer - writer | |
Re: 1st - your program should throw an error if both the w and r starts at the same position. I am not understanding your question well, is that you have a problem distinguishing the position of the R? Whats your program trying to simulate? | |
Re: Here is one of my beginning projects last year : [code] const int row = 1; for(int i = 0; i < row; i++) { for(int j = row-i; j ; j--) cout<<" "; for(int k = i*2; k >= 0; k--) cout<<"*"; cout<<endl; } for(int i = row; i … | |
Re: Try ::px = ((rect.right - rect.left) / 2) - 60; I am assuming there is a local variable hiding the global. | |
Re: [URL="http://stackoverflow.com/questions/199333/best-way-to-detect-integer-overflow-in-c-c"]Google[/URL] is your friend. Particularly check the first post. It talks about using MSB to detect overflow. | |
Re: Here is another way you might want to try. Its in c++ though. You could try to convert it into c. [code] float GetFloat() { std::cout<<"Enter a number please : "; float num(0); cin >> num; while(!cin) { cin.clear(); while(cin.get() != '\n') continue; cout<<"\nPlease enter a number : "; cin … | |
Re: [code]int twodee[5][5];[/code] creates a 5x5 matrix. To draw a graph you might have to use some sort of GUI | |
Re: Do you know the conversion formula from Fahrenheit to Celsius? If so the rest should be formatting issues. Use a loop from i = 20 to i <= 300, and use the conversion formula and display the corresponding Celsius to a Fahrenheit, or vice versa. | |
Re: See if this could help you. It is my string class assignment operator function. [code] Letters& Letters::operator =(Letters& Str1) //assignment operator { if(this == &Str1) //check for self assignment return *this; delete [] str; Len = Str1.Len; str = new char[Len+1]; strcpy(str,Str1.str); str[Len] = NULL; return *this; } [/code] I … | |
Re: I think you can just do the following : get the user input. Find '?' character. Replace '?' character with some other letter. Check for valid word. save it to result list. | |
Re: I don't know if this was mentioned, but when you have a function pointer like for example, float (*pF)(float) , you can only pass it a function that has the same prototype. For example : [code] void drawGraph( float (*graphFunc)(float x) , float leftBound, float rightBound, float epsilon ) { … | |
Re: If you print them side by side then it would make a blank diamond shape in the middle. So instead of creating different shape 1 by one, try to think about the whole shape as one. In fact, draw it on a piece of paper, and try to think of … | |
Re: here is one that I use sometimes. Note that this does not work for every bitmap images. [code] int LoadBitmap( wchar_t* filename) { GLubyte* pixels; HBITMAP hbmp; BITMAP bmp; GLuint size; GLenum format; GLuint totalBytes; texID++; hbmp=(HBITMAP)LoadImage(GetModuleHandle(NULL), filename, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE ); if(hbmp==NULL) { MessageBox(NULL,L"ERROR : CANNOT … | |
Re: [QUOTE=Tom Gunn;951013] [code=cplusplus] // code intentionally advanced to deter cheaters #include <algorithm> #include <functional> #include <iostream> #include <iterator> #include <numeric> #include <vector> #include <cmath> template <typename T> struct SquareOfDiff: public std::binary_function<T, double, T> { T operator()(T x, double mean) const { x -= (T)mean; return x *= x; } }; … | |
Re: On an alternative note, there is std::sort() function. | |
Re: Go for class structure. It will definitely be a lot easier and less work, as well as more elegant. Here are some ideas : [code] class Hero{}; class BigHeadMonster { }; class Items { }; class Story { }; Class Map { }; [/code] Pick a class, start implementing it, … | |
Re: This is cute. First of, look at the patterns. Tell me what you can figure. Its interesting how the patterns unfolds. Just look at the result : [code] a b c b c d e d c d e f g f e d e f g h i h … | |
Re: Its much easier than you are making it. [code] cin >> limitNum; for(int i = 0; i < limitNum; i++) cout<<i<<" "; [/code] |
The End.