15,300 Posted Topics
Re: >>unsigned char byte2[1]="0X"; Wrong. You tried to stuff two characters in an array that can only hold one. Something like me trying to stuff my gut into pants that are too small. You didn't say whether you are allowed to use standard C functions or not. If you are, then … | |
Re: [QUOTE=gerard4143;1165999]If this is a Linux/Unix program then you have to compile with -lcurses gcc filename.c -o filename -lcurses[/QUOTE] Why? getchar() is defined in stdio.h not curses.h. Oh wait a minute -- you were talking bout getch() which might be in curses. I don't think that's the one the op was … | |
Re: It depends on the contents of the file -- every binary file is different. In a nutshell, use ifstream's read() method. | |
Re: Probably not. I suppose you could keep it encrypted, but even that will not prevent some smart hacker from decrypting the password. There really is no bullet-proof way to save passwords, anywhere except in the human mind. | |
Re: [QUOTE=Banfa;1164785] People just continue to use 0 rather than EXIT_SUCCESS because it is rather easier to type.[/QUOTE] Old timers like me use 0 out of habit. I started programming before c++ was invented, and even before there was such a thing as function prototype. Magic numbers were the norm in … | |
Re: Aia brought up one of the reasons I recommended strtol() instead of strtok(). With strtol() you can make each of the conversions in one single line of code (one for each variable), and no loops. | |
Re: >> #include <stdio.h> Delete that line. This is c++ program, not C. When posting code put it in code tags[noparse][code] // your code goes here [/code][/noparse] so that we can read it. | |
Re: use it just like you would any POD (Plain Old Data). Your question is so vague that all I can give you is a vague response. | |
Re: Your options are NOT either Dev-C++ or BUY a commercial compiler. There are several very good free compilers. Both Code::Blocks and VC++ 2008 Express are free. Dev-C++ is no longer recommended because it's pretty much dead and is installed with an old version of the MinGW compiler. If you are … | |
Re: you can use strtol() which avoids at least one of the problems with strtok(). | |
Re: If you think your software is so great, you can spend a few million of your own money for packaging, advertisment, and distribution. Or, if you aren't quite that confident or wealthy, you can put it on the net as shareware. | |
Re: [quote] The user enters a name and then decides he/she wants to display the name via the saved list, but once they enter the name, they cant display the entered name in the saved list straight away ...[/quote] The solution is to save the new name in the list as … | |
Re: what compiler do you have? If you have Dev-C++ then you will have to download the windows package using the Dev-C++ IDE package manager. I think there is a menu item for that. | |
Re: >>API should be in the form of static library. There are two kinds of libraries -- static libraries and import libraries (or dlls). When you create a new win32 project you have a choice of Windows Application, Console Application, DLL or Static Library. Choose the last one. I suppose they … | |
Re: what do you mean you want to convert it to binary? Like the letter A (which has a decimal value of 65) = 1000001? | |
Re: I'll bet you are trying to run that program under MS-Windows version XP or newer? If that is true then you can not run that program on your os. Install Win98 or MS-Dos Version 6.X and try again. I know that's not what you want to hear but that's the … | |
Re: You can't assign the variant like that because _bstr_t owns the memory. [code] int main() { _bstr_t a = (L"Joe Schmoe"); _bstr_t b = (L"Accounting"); VARIANT vtEmpName; VARIANT vtDept; vtEmpName.vt = VT_BSTR; vtEmpName.bstrVal = a.Detach(); vtDept.vt = VT_BSTR; vtDept.bstrVal = b.Detach(); } [/code] you can also do it like this: … | |
Re: Read the file by line, not by character because you will need to parse the words in the file in order to find key words. So read the file using getline() instead of get(). To do #4 you will have to make an array of key c++ words. The easiest … | |
Re: Did you create a console project? e.g. File --> new --> project then select Console Application in the popup box. | |
Re: you will have to post the entire program because there is no way anyone can determine the problem from the little code you posted. | |
Re: The code you posted has nothing to do with the problem. Try posting again but this time make sure you post the correct program. | |
| |
Re: while loop is incorrect. You need to read all the records, not just the first one for that doctor. BTW writing short programs to solve a specific problem save you a lot of time. [code] #include <stdio.h> #include <string.h> struct doctor { char name[80]; char regis[80]; char pname[80]; char treatment[80]; … | |
Re: Do not put executable code such as lines 27-30 in header files. If you want to make that inline then put it in the class declaration the way you did getName(). You have several functions mis-coded like that. [code] class GrandParent { public: //constructor GrandParent(string name) {_name = name;} //Getter … | |
Re: use c++ fstream class. google and you will find several tutorials. | |
Re: Another reason not to use Turbo C for Windows programming -- it can not be use for that. Turbo C is a 16-bit compiler and can not access any of the 32-bit MS-Windows libraries or DLLs. I didn't realize Turbo C++ Explorer is no longer available. It must not have … | |
Re: [QUOTE=Narue;1157134][B]> A wise man welcomes competition and betters himself, a fool stomps it out so his mediocrity shines.[/QUOTE] You should have told that to Bill Gates & Microsoft :) | |
Re: post the whole program. In the code you posted the variable [b]hydraulicRadius[/b] was not defined. Did you include <math.h> ? | |
There's some rhumors over here USA tabloids that Price William, not his father, will become the next King. Any truth to that? ![]() | |
Re: The best approach is to use standard c++ file i/o classes and methods because that gives your program the best portability should you decide to port it to another operating system sometime in the future. Using win32 api file i/o functions is a little like limiting yourself to only binary … | |
Re: Functions can not use variables that were declared in other functions. You have two choices: pass min and max variables as parameters or make them global so that all functions can use them. Passing as parameters is the preferred way to solve the problem. | |
Re: >>.what can i do replace the current version of MS_Windows with MS-DOS 6.X or Win95. | |
Re: Why don't you use the standard C function fgets()? Or are you not allowed to do that? [code] char name[10]; fgets(name, sizeof(name), stdin); if( name[strlen(name)-1] == '\n') name[strlen(name)-1] = '\0'; [/code] | |
Re: >>I am trying to send the address of the ptr to another sub processor. Huh? Are you using a PC or something else? You also need to post some code if you expect anyone to help you very much. Here's my [b]guess[/b] In C language just use the address operator … | |
Re: line 75: while((clock ()/CLOCKS_PER_SEC)<(hours*3600)){ That is the problem (or majority of the problem). That line is not allowing any other process to run and just hogs up all the cpu time. Depending on the operating system put either Sleep() or sleep() to allow other processes to run. A few other … | |
Re: Read it one character at a time, then if it's not a space add it to a character array. | |
Re: I agree -- when splitting a hijacked post the mods are adding [b]hijack[/b] to the new thread's title. Makes it easy to know why the first post in the new thread might be a little confusing. | |
Re: >>inQuiz.seekg(0);//set position to begining of file Delete that line. When the file is opened the file pointer will already be set to the beginning of the file. >>inQuiz.seekg(1 - 1, ios::cur); Why? what purpose does that serve? | |
Re: lines 171-176: what's the purpose of that loop? Just delete it. | |
Re: @GrimJack: I saw something like that picture on tv once -- Oh yes, it was on Star Trek NG. | |
Re: [QUOTE=kng;1159976]Just for the book i am applying a ton of compression techniques but lets just say for some reason we still can't be able to fit the entire structure onto main memory what would you do?[/QUOTE] you might have at least a couple choices [list=1] [*] Use a 64-bit compiler … | |
Re: vc++ uses Forms it you create a C++/CLR project, which is Microsoft specific I think. [URL="http://winprog.org/tutorial/"]Here [/URL]is a tutorial how to create a gui from pure win32 api functions. Or you might try [URL="http://www.wxwidgets.org/"]wxWidgets[/URL] | |
Re: what makes you think an int is only 16 bits? Depending on your compiler, it might, but then again it might not. | |
Re: line 14 of CMain.h -- global objects can not be declared in header files because the compiler will try to create them in each *.cpp file in which the header file is included. Instead, use the [b]extern[/b] keyword in the header file then in one, and only one *.cpp file … | |
Re: put a dot in from of the / character, e.g. "./blabla" | |
Re: My dream computer would be a hologram that computes in the future and returns the results to the present, like in Star Trek Next Generation. | |
Re: switches with multiple variables is no supported, just as you thought it might not be. But ... if you convert the rgb values into [URL="http://msdn.microsoft.com/en-us/library/dd162937%28VS.85%29.aspx"]COLORREF[/URL] value then you could use that in the switch statement. | |
Re: Sorry for being 3 months late with this. Nice function -- a couple minor tweeks to make it run faster, but nice anyway. |
The End.