868 Posted Topics

Member Avatar for atrusmre

[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 …

Member Avatar for atrusmre
0
176
Member Avatar for bops

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 …

Member Avatar for Ancient Dragon
0
546
Member Avatar for mina1984

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 ) …

Member Avatar for mina1984
0
110
Member Avatar for TimC

[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 …

Member Avatar for TimC
0
163
Member Avatar for atrusmre

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.

Member Avatar for perniciosus
0
522
Member Avatar for TimC

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 …

Member Avatar for winbatch
0
289
Member Avatar for nabil1983

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.

Member Avatar for SpS
0
175
Member Avatar for smaity
Member Avatar for TimC

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, …

Member Avatar for WolfPack
0
164
Member Avatar for akki_freak
Member Avatar for WolfPack
0
80
Member Avatar for ilikerps

[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]

Member Avatar for ilikerps
0
122
Member Avatar for nabil1983

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); …

Member Avatar for HyperEngineer
0
144
Member Avatar for j1979c

[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 …

Member Avatar for Ancient Dragon
0
126
Member Avatar for TimC

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.

Member Avatar for WolfPack
0
102
Member Avatar for ilikerps

use the [URL=http://www.cplusplus.com/ref/cstring/memset.html]memset[/URL] function.

Member Avatar for SpS
0
503
Member Avatar for StealthCobra

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]= …

Member Avatar for StealthCobra
0
118
Member Avatar for j1979c

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 …

Member Avatar for jwenting
0
206
Member Avatar for btech

[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.

Member Avatar for iamthwee
0
241
Member Avatar for akki_freak

[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]

Member Avatar for Rashakil Fol
0
354
Member Avatar for vicky_dev
Member Avatar for ajit.nsit
0
187
Member Avatar for fidelljf

[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 …

Member Avatar for WolfPack
0
72
Member Avatar for fidelljf

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]

Member Avatar for fidelljf
0
103
Member Avatar for ilikerps

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 …

Member Avatar for ilikerps
0
131
Member Avatar for TimC

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 …

Member Avatar for winbatch
0
264
Member Avatar for atrusmre

[CODE]CMenu* menu = GetMenu(); CMenu* submenu = menu->GetSubMenu(0); submenu->EnableMenuItem(ID_MENUITEM_YOU_WANT_TO_ENABLE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);[/CODE]

Member Avatar for atrusmre
0
165
Member Avatar for ToySoldier

Change the last line of your while loop to this [code] infile>>first>>last>>ss>>st_code; [/code]

Member Avatar for ToySoldier
0
195
Member Avatar for Loopah
Member Avatar for Keyonts

[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 …

Member Avatar for WolfPack
0
154
Member Avatar for iqbal
Member Avatar for kahaj

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 …

Member Avatar for SpS
0
897
Member Avatar for slobo7x

[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 ; …

Member Avatar for perniciosus
0
464
Member Avatar for Cudmore

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 …

Member Avatar for perniciosus
0
218
Member Avatar for bucsoldier03
Member Avatar for dwks
0
227
Member Avatar for bucsoldier03

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, …

Member Avatar for dwks
0
155
Member Avatar for ToySoldier

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]

Member Avatar for perniciosus
0
226
Member Avatar for 123abc

[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.

Member Avatar for WolfPack
0
254
Member Avatar for HyperEngineer

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]

Member Avatar for WolfPack
0
102
Member Avatar for mtodd51

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, …

Member Avatar for WolfPack
-1
653
Member Avatar for snaidis

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]

Member Avatar for Narue
0
377
Member Avatar for atrusmre

[URL=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_cstring.3a3a.getlength.asp]CString::GetLength[/URL]

Member Avatar for server_crash
0
176
Member Avatar for Acidburn

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]

Member Avatar for WolfPack
0
84
Member Avatar for imanust

[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 …

Member Avatar for WolfPack
0
99
Member Avatar for Muralish
Member Avatar for WolfPack
0
56
Member Avatar for Loopah

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 …

Member Avatar for Loopah
0
633
Member Avatar for kahaj

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.

Member Avatar for Dave Sinkula
0
240
Member Avatar for DotNetUser

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.

Member Avatar for DotNetUser
0
130
Member Avatar for johnray31
Member Avatar for vicky_dev

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 …

Member Avatar for WolfPack
0
221
Member Avatar for HyperEngineer

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

Member Avatar for WolfPack
0
130
Member Avatar for juusan

The End.