- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 55
- Posts with Upvotes
- 45
- Upvoting Members
- 30
- Downvotes Received
- 59
- Posts with Downvotes
- 38
- Downvoting Members
- 22
I live in Romania somewhere near Bucharest.I'm currently working as a cinema projectionst.
- Interests
- D&D,RPG,RTS,TBS games and of course .. programming
- PC Specs
- Windows Xp Sp3 using Borland 5.5 C++ and MinGW compilers.Linux Mint 11.
201 Posted Topics
Re: Try creating a new Pig ;)).First declare a pointer to a pig like this [code]Pig* Oliver[/code].Then assign a new Pig () to it like this.[code]Oliver=new Pig();[/code].When you're done feeding and killing him ;)) delete de poor pig from memory.[code]delete Oliver;[/code].And maybe you should join PETA .. | |
Re: I couldn't find your problem but as a suggestion i'd say you should focus more on how you structure your program so that you eliminate much of the overhead by breaking the design in more pieces of functionality.The code becomes more readable and more easy to modify that way.I wrote … | |
Re: [code] #include <iostream> #include <cmath> #include <sstream> int pth (int x,int y) { return std::sqrt (std::pow(x,2)+std::pow(y,2)); } int main (int argc,char* argv[]) { int c=0; int r; std::istringstream i(argv[1]); i >> r; const int width=r; const int length=r*1.5; for (int y=width;y >= -width;y-=2) { for (int x=-length;x <= length;x++) { … | |
Re: I too am looking for a job:">. Is this the idea? (I don't know assembly too well) For loop: [code] for (int x=0;(x*2)<100;x++) {} mov eax, 0 @head: ;;loop body inc eax imul 2 cmp eax, 100 ja @end jmp @head @end: [/code] While loop: [code] int x=5; while (x) … | |
Re: [code] ifstream in; in.open("filename",std::ios::app); in.seekg(in.tellg(),std::ios::end);//this places the file pointer at the end [/code] | |
Re: [code] #include <iostream> #include <vector> #include <math> using namespace std; struct point { int x;int y; point () {} point (int a,int b) : x(a) , y(b) {} friend float dist (point a,point b) { int p1; int p2; (a.x>b.x) ? p1=a.x-b.x : p1=b.x-a.x; (a.y>b.y) ? p2=a.y-b.y : p2=b.y-a.y; return … | |
Re: Deleting the root of a tree won't free the memory allocated for the other nodes. You will lose ownership of the memory allocated by disowning the other left and right pointers. Doing this [code] int* y=new int(5); y=new int(6); //lost ownership of (new int(5)) [/code] will create a memory leak. … | |
Re: The postfix increment operator returns the current value after which it increments it but you still get a 5. Try the prefix operator to see the difference. | |
Re: You need specify each file's dependencies and the way they are built. //11.o's recipee 11.o : 11.c 11.h $(CC) $(CFLAGS) $< -o $@ //main.o's recipee main.o : main.c $(CC) $(CFLAGS) $< -o $@ //and finally the main program all : main.o 11.o $(CC) $? -o main_proj.exe | |
Re: Your formula needs to be computed inside a function so at line 11 you have a big error as you are trying to initialize an integer variable with the result of an operation of three other uninitialized variables. [code] //ex float density(float mass,float volume) { return mass/volume; } [/code] | |
Re: [code] #include<stdio.h> #include<stdlib.h> void doTaskA(){ printf("Start of Task A\n\n"); int input_1, input_2, input_3; printf("Start of TASK A\n\n"); printf("Please enter 3 integer.\n"); scanf("%d\n%d\n%d",&input_1, &input_2, &input_3); if ((input_3>input_1) && (input_3>input_2)) printf("/nThe biggest number is %d\n", input_3); else if ((input_2>input_1) && (input_2>input_3)) printf("/nThe biggest number is %d\n", input_2); else printf("/nThe biggest number is … | |
Re: [code] #include <iostream> #include <deque> #include <string> #include <limits> #include <sstream> #include <iomanip> #include <cmath> /* Obtaining square root using the decimimal method */ class square_root { double result,tmp,rmndr; long input; double decim; //Will contain the number of trailing decimimals. std::deque<double> tokens; //Will contain the tokenized 'input' value. square_root (); … | |
Hi everyone.I'm trying to compile a resource file ".rc" for a Win32 application but i'm getting this error "use "" to put " in a string".Among other things , i'm trying to define a MENUITEM with a string that looks like this "&Save\t\"Alt+S\"".i have tried escaping the '"' character with … | |
Hi.I get the following error "g++: error: CreateProcess no such file or directory" whenever i try to compile a program.I have installed the MinGw 7.2 version at work on a windows machine and the problem does not occur , however after installing windows SP3 on my home computer i get … | |
Re: You are redeclaring 'x' and 'y'.They have already been declared in the argument list so in lines 37 and 38 you should just assign to those variables and lose the 'double' specifier. | |
Hello.I've been looking for a free C++ compiler for windows which supports the new standard features but i had little luck so far.Does someone have any knowledge of one? Thank you in advance. | |
Re: The error is in function Delete_Font where ADC is an argument of type HBRUSH instead of HDC. | |
Re: I think that in the conditional expression the 8 bits variable gets promoted to a 16 bits wchar_t. | |
Re: Enumerations are constant expressions with static duration which means they cannot be modified during runtime.The declaration [code] enum foxtrot {green, yellow, red}; [/code] is equivalent with [code] typedef enum {green,yellow,red} foxtrot; [/code] in which case you are creating an alias for each enumeration's type.You need an explicit cast (type conversion) … | |
Re: [CODE] #include <iostream> #include <fstream> int main () { std::ifstream file("asd.txt"); std::ofstream resfile("dsa.txt"); int x=0; int result=0; char sign='+'; while (!file.eof() && !file.fail()) { file >> x; file >> sign; if (sign=='+') { result+=x; } else break; } resfile << result; resfile.close(); file.close(); } [/CODE] | |
Re: I don't think you need the second while loop.Also post your find_original implementation. | |
Re: I've had this issue once.You need to rerun the configuration batch file (.bat | .cmd) situated in the bin\ directory. | |
| |
Hi.Someone asked a day or two ago for a way to extract the square root of a number without using the std::sqrt function so i thought about writing my own.Here it is and please feel free to criticize. | |
Re: You need to initialize an OPENFILENAME structure which defines a dialog box.A call to GetOpenFileName() with the required arguments will create the dialog box.Look that up on msdn. | |
Re: [code] std::string asd="234+34"; char plus; int first,second; std::stringstream (asd) >> first >> plus >> second; [/code] | |
Re: You could start off by creating a class say 'Worker' which would represent specific data like name,weekly hours,untaxed wage etc.Then a class Payslip who's constructor takes a worker as an argument and applies taxes and subtracts social contributions emitting a list of all the operations being done and the total … | |
Re: You need a pair of brackets even if you don't provide arguments for a function. ;) | |
Re: [URL="http://homepage.mac.com/guyf/DnD/DnDRulesFAQ.html"]http://homepage.mac.com/guyf/DnD/DnDRulesFAQ.html[/URL] | |
Hi.I have a piece of code that compiles without even a warning on the borland 5.5 compiler yet complains bitterly when compiling with g++.I've heard that g++ emits more portable code but shouldn't they both be standard compliant?From what i've read in the '98 standard book this should be legal … | |
Re: Extended initializer lists are only available with C++0x.Maybe you should assign each element by directly indexing it[code] userInput[0]=user[5]; userInput[1]=user[6]; [/code] | |
Re: You need to send the edit control an WM_GETTEXT message and pass ca C string as the WPARAM argument along with the size of the string in the LPARAM arg.The string pointed to by the WPARAM parameter will receieve the text contained by that edit control. | |
Re: [URL="http://www.codeproject.com/KB/office/BasicExcel.aspx"]http://www.codeproject.com/KB/office/BasicExcel.aspx[/URL] | |
Re: The window doesn't get the input focus in case of a WM_PAINT message rather it invalidates a specific region of itself and redraws it ( like when you drag another window on and off the surface of your main window ) or draws the specific child windows that are created … | |
Re: You need owner draw buttons.That means you have to create the necessary shapes or bitmaps to resemble each state of a button.There is a style for this which you pass as an argument in the CreateWindowEx function(BS_OWNERDRAW) but the part of drawing each state in case of a WM_COMMAND message … | |
| |
Re: Sergent I just wanted to thank you for that link... hours of fun :D | |
Re: This is just so you can get the idea.You should use higher constructs like strings vectors and stringstreams. [code] #include <cctype> #include <cstdio> int main () { char arr[]={"@@123124125@@@"}; int packcount=0; int lettercount=0; char pack[10][3]={0}; for (int x=0;x<sizeof(arr);x++) { if (std::isdigit(arr[x])) { pack[packcount][lettercount]=arr[x]; lettercount++; } if (lettercount==3) { packcount++; lettercount=0; … | |
Re: If you use visual studio the structure of the program will already be created.A program must register a CREATESTRUCT structure in which you initialize a pointer the main window procedure and several other mandatory variables.Then the class is registered through the RegisterClassEx function.Then the window gets created with the CreateWindowEx … | |
Re: 1) You sure can but they must be initialized thus declared static [code] class A { static const asd=10; }; [/code] 2) A friend function gains access to private or protected data members of a class.It must be declared in the body of the class's declaration and does not receive … | |
Re: Your get_it() function should only act as an accessor and you need a static instance of the class not just a pointer. [code] class A { static A b; A () {} public: ~A () {} static A Get ( { return b; } }; int main () { A::Get(); … | |
Re: It is a conditional statement of the form [(boolean expression evaluation) ? (execution in case of true) : (execution in case of false)].Much like an if else statement.In this particular case if (hour<10) will evaluate to true a "0" will be inserted first in the cout stream and a "" … | |
Re: If you created the dialog using the CreateDialog function the last function argument should be a pointer to the callback function CalculatorProc.Don't forget to modify that too. | |
Hi guys.Does anyone who studied the implementation of stringstreams know if : [code] char c; std::stringstream ss; ss << std::fstream ("file.xml",std::ios::in).rdbuf();//this is eqaul in terms of speed while (ss.get(c)) {} //with this? std::ifstream f("file.xml"); while (f.get(c)) {} //or this? [/code] Thanks a lot. | |
Re: Much simpler : [code] #include <iostream> #include <sstream> #include <string> #include <fstream> class Item { std::string Name; int Qty; int Price; public: Item (std::string Name_,int Qty_,int Price_) : Name(Name_),Qty(Qty_),Price(Price_) {} Item () {} ~Item () {} friend std::istream& operator >> (std::istream& i,Item& it) { return i >> it.Name >> it.Qty … | |
Re: Or much more simple you could create a main win32 project and not define or register a window class: [code] int __stdcall WInMain (HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR szCmdArg,INT nCmdShow) { //code here MessageBox (NULL,"Output",NULL,MB_OK); //output stuff } [/code] | |
Re: First of all you should provide a default constructor for your class as for the error you're getting you should take a better look at your initialization list keeping in mind that you should provide valid arguments for the constructors of the classes you are inheriting from. | |
Did someone reset the down votes for bad membmers ?:D If not .. i'd like to thank whoever got me rid of all those -33 down votes received since i've been a member here.Otherwise if it's a mistake maybe i should get them back since it helped me remind myself … | |
Re: You need a handle to a device context since GetPixel needs one as it's first argument.It returns a COLORREF object which consists of the amount of red green and blue that give the pixel it's color. | |
Re: isdigit(char) returns a boolean value indicating whether the argument recieved was numeric or else.You must include <cctype> in order to use this function. |
The End.