868 Posted Topics
Re: [QUOTE=atrusmre]If I have a MFC program that opens a socket connection, how would I test to see if the socket has succesfully opened or not?[/QUOTE] almost any function in the winsock api returns the value SOCKET_ERROR in the event of failure. you only have to check this for errors. if … | |
Re: well, if the number of controls is small, using global variables is okay. but i prefer to create them locally inside the create function and then use GetDialogItem API to get the handles of the controls when i need them. this eliminates the need of global window handles and makes … | |
Re: Since you have functions that determine [QUOTE]If the year is a leapyear how many days the month in the dates have[/QUOTE] the rest is easy. Your function to output the number out of the total days in an year should be something like this [code] int ReturnNumberOutOfTotalDays( Date date ) … | |
Re: [code]#include <iostream> using namespace std; int main(int argc, char *argv[]) { char no ; do{ cout<<"Enter a Number"<<endl; cin>>no; cout<<no<<endl; } while ( no != '5' ); system("PAUSE"); return 0; } [/code] This is much better. Wont go mad at characters. But you will have to guard against multiple characters … | |
Re: Well perni's solution should work. But why cant you use a normal array like [code]char pBuf = char[1000025][/code]? It will cleanup itself as it goes out of scope. Saves you a lot of trouble. | |
Re: Well what do you mean by running only once? I compiled and ran the program, and it ran okay. I added two patients, one doctor and printed the patient and doctor list, all by one go at the program. The other options didnt work as I think you have to … | |
Re: I dont think it is a sorting function at all. All it does is ask the user for a name, searches the database for a match, and once a match is found display the information the user wants to see. Nope, no sort. | |
Re: unichar can be more than 2 bytes? I thought it was always 2 bytes. | |
Re: If you want to do the detail entering and the detail printing seperately, you should define a doctor array inside the main function, and pass that function name to the two functions you are using ( Enter_Doctor_Details(), and Print_Doctor_Details() ). Better if you look up for, global scope, local scope, … | |
Re: try [code]"C:[color=red]\\[/color]q.txt"[/code] as the file name. | |
Re: [code] vector <char*> constArray(10); char* changingString = "hello"; constArray[0] = new char; constArray[0] = changingString; changingString = "yadayada"; printf("constArray[0] = %s\nchangingString = %s\n", constArray[0], changingString); [/code] | |
Re: try this [CODE]int top=0; int filewrite(void) { int i; char years[4]; char ch[2]; for(i=top;i<1;i++) { printf("Press Y to Continue or N for Menu"); gets(ch); printf("Enter the artist: \n"); gets(cd[i].artist); printf("Enter the album: \n"); gets(cd[i].album); printf("Enter label name: \n"); gets(cd[i].label); printf("Enter year: \n"); gets(cd[i].year); printf("Enter the genre of music: \n"); gets(cd[i].genre); … | |
Re: [QUOTE=j1979c]Now let me see -- which is more recent compiler, 2003 or 2005? [/QUOTE] Now let me see -- which came first? World War 1 or World War 2? :cheesy: ehehehe. Well if you think you have mastered C++ I dont think it is difficult to migrate to a different … | |
Re: Define the Constructors for junior and consultant. [CODE]junior::junior()[/CODE] and [CODE]consulant::consultant()[/CODE] , or remove the [CODE]junior(); [/CODE]and [CODE]consultant();[/CODE] lines in the class declarations. | |
Re: use the [URL=http://www.cplusplus.com/ref/cstring/memset.html]memset[/URL] function. | |
Re: Dont use same variable names. It makes it confusing to you and creates bugs that are very hard to find. [CODE] void findLowest(double grades[4][5], double average[4], double lowest[4]) { for (int x = 0; x < 4; x++) { double [COLOR=Red]low[/COLOR];//declare a variable here to hold the lowest score [COLOR=Red]low[/COLOR]= … | |
Re: I personally believe that following the Petzold Book ( I believe that is the book number one in your list ), is the best when starting GUI programming in Windows. So before starting on MFC you better go through that. Initially the Applications will look ugly, due to the use … | |
Re: [CODE]void stackType<Type>::push(const Type& newItem) { if(![color=red]isFullStack()[/color]) // You havent defined this member function. { list[stackTop] = newItem; stackTop++; } else cerr<<"Cannot add to a full stack."<<endl; }[/CODE] ALso [CODE]string rpn(string infix)[/CODE] is not returning a string value. ![]() | |
Re: [QUOTE=akki_freak]Write a "Hello World" program in 'C' without using a semicolon. [/QUOTE] [code] #include <stdio.h> int main() { while( !printf( "%s", "Hello World\n" ) ) { } } [/code] | |
Re: while( str[i] != ' ' [color=red]&&[/color] str[i] != '\0' ) | |
Re: [CODE]void initPlane(char plane[NUMROWS][NUMSEATS]); // POSTCONDITION: // plane[x][0] == 'A', 0<=x<=6 // plane[x][1] == 'B', 0<=x<=6 // plane[x][2] == 'C', 0<=x<=6 // plane[x][3] == 'D', 0<=x<=6 void printPlane(char msg[], char plane[NUMROWS][NUMSEATS]); // POSTCONDITION: The seating layout of the plane has been printed // to the standard output with an X displayed … | |
Re: Shouldnt [code]for (index = 9; index<0; index--)[/code] be [code]for (index = 9; index[COLOR=Red]>=[/COLOR]0; index--)[/code]. And since you are passing the size of the array use that instead of the hard coding 9. Like this[code]for (index = size; index>=0; index--)[/code] | |
Re: No, your question is not stupid. If is one that occurs to all beginners in socket programming. Actually all 3 of your options are possible. So I will give you the answer for the first question which is I think the easiest and good to get some exposure to thread … | |
Re: Yes it is possible. But the problem is you are not saving it to a variable in the main function. The variable [CODE]option [/CODE]is declared inside the display_function so the main function does not know about it. Change your code as below and it will work. [code] #include "display.h" int … | |
Re: [CODE]CMenu* menu = GetMenu(); CMenu* submenu = menu->GetSubMenu(0); submenu->EnableMenuItem(ID_MENUITEM_YOU_WANT_TO_ENABLE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);[/CODE] | |
Re: Change the last line of your while loop to this [code] infile>>first>>last>>ss>>st_code; [/code] | |
Re: Yes it is possible. | |
Re: [CODE] void bumpPlane (plane*& pstart) { int flight; cout << " Enter the flight number you would like to move ahead" << endl; cin >> flight; plane* ptarget = NULL; plane* pcurrent; pcurrent = pstart; plane* pbefore = NULL; if(pstart == NULL) [COLOR=Red]{[/COLOR] /[COLOR=Blue]/ better to get used to using … | |
Re: and give us the compile errors. | |
Re: Lets say you have a global variable and a local variable with the same name. When you compile it, the compiler will use the local variable, and not the global variable. If you prefix the variable name with ::[variablename], then the compile uses the global variable. [code] #include <iostream> using … | |
Re: [QUOTE=perniciosus]no need to redo what has already been done grep -n word file or to use it in that context once you got the string do [code] char *arg[5] ; arg[0] = "grep" ; arg[1] = "-n" ; arg[2] = string.c_str() ; arg[3] = fileName.c_str() ; arg[4] = NULL ; … | |
Re: Here is a running code. You will have to clean it up more.[CODE]// My First Internet Application // By Matthew Cudmore, 2005 #include <iostream> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <unistd.h> // For gethostname #define MYPORT 4689 #define QUEMAX 10 #define BUFFER_LEN 100 #ifndef SOCKET_ERROR #define SOCKET_ERROR … | |
| |
Re: The declaration `void getdata(ifstream fin);` and its definition int getdata(ifstream fin, ofstream fout) { ... } does not match. You will get a link error. Also I think I see a mismatch in the {} braces. This also should give you an EOF not found error. Use properly indented code, … | |
Re: could it be that infile and outfile are not defined? It would help if you posted the compile errors. [CODE]outfile.open("report.txt"); infile.open("people3.txt");[/CODE] | |
Re: [QUOTE=123abc]how am i spamming the forum?[/QUOTE] he he he :cheesy:. Sunny didnt mean you dude. Didnt you see the quote in his message? It was meant for that advertising fellow sam_dee who was trying to promote some company, maybe his, in these threads. | |
Re: 1. Add a Control Variable of type CStatic to the Static Control( lets say m_Caption ) 2. Add a CFont Private Variable to the Main Dialog ( say m_Font ) 3. At the OnInitDialog Function do this [code] m_Font.Detach(); m_Font.CreatePointFont(360, "Arial", (GetDlgItem(IDC_PROGRESS_INDICATOR) )->GetDC()); m_Caption.SetFont(&m_Font ); [/code] | |
Re: A start for windows. Modify to your requirements.[URL=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/console_functions.asp]Further Reference[/URL] [CODE] #include <iostream> #include <windows.h> int main() { DWORD dwWritten; HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_SCREEN_BUFFER_INFO ConsoleScreenBufferInfo; GetConsoleScreenBufferInfo(hConsole, &ConsoleScreenBufferInfo); COORD coordCurrent = ConsoleScreenBufferInfo.dwCursorPosition; for ( int j = 0 ; j < 10 ; j++ ) { FillConsoleOutputCharacter(hConsole, j + toascii('0'), 1, … | |
Re: That is a mathematics question and explanation is lengthy. It is mostly used in numerical series. Best thing is to go to a mathematics site and search in it. Here is a [URL=http://en.wikipedia.org/wiki/Factorial#Applications]sample[/URL] | |
Re: [URL=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_cstring.3a3a.getlength.asp]CString::GetLength[/URL] | |
Re: Loop until you find an EOF. Something like this? [code] while((ch = infile.get()) != eof ) { if ( ch != space ) { cout <<"\nRead value is : "<< ch<<endl; cout << "calling function : "; populateArray(ch, i); } } [/code] | |
Re: [QUOTE=imanust]Thank you Dave. that is what my teacher told me as well. i am quite new to c++. where exactly do i include the spaces? how will the loops will look like? cheers[/QUOTE] Being new to C++ is not a factor here. Write down a Grid in paper. Any number … | |
Re: Check the [URL=http://beej.us/guide/bgnet/]beejs guide[/URL]. | |
Re: Or something similar to this. [CODE]int occ( int Grid[ ROW ][ COLUMN ], int x, int y ) { int neighbourCount = 0 ; for ( int i = max( 0, x - 1 ) ; i < min( COLUMN, x + 1 ); i++ ) { for ( int … | |
Re: change the headers as [CODE]#include <iostream> #include <[COLOR=Red]cstdlib[/COLOR]> #include <iomanip> #include <[COLOR=Red]ctime[/COLOR]>[/CODE] include the following statement after the include statements [CODE]using namespace std;[/CODE] OR append [CODE]std::[/CODE] before [CODE]cout ,endl, setw[/CODE]. For ex. [CODE]std::cout <<[/CODE] Put a [CODE]std::cin.ignore( ); [/CODE]before the return statement. | |
Re: Probably you missed some steps in setting up the timer. Give us the steps you carried out upto now. Oh and tell us if it is a MFC or Win32 Application. | |
Re: I think he said "without using extra space". | |
Re: Try this for Windows. It writes itself a Batch File and runs it. After the Exe File is deleted, the batch file also deletes itself. A reboot isnt needed here. [CODE] #include <iostream> #include <fstream.h> #include <windows.h> #include <shellapi.h> int main( int argc, char* argv[] ) { char ExeFileName[ 260 … | |
Re: Try the [URL=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_cwnd.3a3a.getclientrect.asp]GetClientRect[/URL] method of the CWnd class. However the coordinates are with respect to the FrameWindow. You will need some calculations to get it w.r.t the screen. [URL=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_cwnd.3a3a.getwindowrect.asp]GetWindowRect[/URL] gives the coordinates of the Frame window w.r.t. the screen | |
The End.