|
|
C/C++ arrays are 0-based, i.e. if you declare:
int a[5];
then you have the following items:
a[0], a[1], a[2], a[3], a[4];
on the other hand, a[5] , is out-of-bounds.
so the correct iteration will be
for (i = 0;i<5;i++)
a[i]= (whatever);
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
thanks!
*
|
|
|
|
|
int A[5][5];int A[6][6];
Code-Frog:So if this is Pumpkinhead. Time for him to run and hide. It's an interesting thought really.
|
|
|
|
|
|
in a way it's future proof . Just kidding!
Code-Frog:So if this is Pumpkinhead. Time for him to run and hide. It's an interesting thought really.
|
|
|
|
|
This will surely work, but the poor guy will never come to know what is wrong with his approach! I think thats the reason for you being voted down. (I gave a 5 to bring u up because you put your time and efforts and shouldn't get voted down)
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
|
I decided to add my 1 to the vote, because 0 was not a choice. You received a 1 vote because you did not provide an answer to the question. If the person asking the question understood your [joke] answer then they would not have needed to ask it in the first place.
Sorry, but the idea is to help and not make fun of the person asking the question.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
hmm
Code-Frog:So if this is Pumpkinhead. Time for him to run and hide. It's an interesting thought really.
|
|
|
|
|
It seems that on this forum we must only answer to questions;)
|
|
|
|
|
Thanks
*
|
|
|
|
|
In these lines:
if (j-1 > 0 && i+1 <=5 )
{ if (A[i][j] < A[i+1][j-])
"i" can be as large as 4. Which means elements A[5][j] are being accessed - but the declaration was int A[5][5] - i.e. the maximum element is A[4][j]
So array out of bounds ..
cheers,
Neil
|
|
|
|
|
Hi Jobin,
I have created a simple example to simulate TCP using MFC CSocket. The purpose of the code is Server Listens at port number 6000. Once client gets connects to 6000, client sends a message to Server and the server should display the received message. The server code is running correctly in the Application generated by AppWizardExe (include windows sockets check box Yes)but not at console based program.
The code is as follows
s.Create (6000);
s.Listen ();
s.Accept (t);
n = t.Receive ((void*)l,20);
l[n] = 0;
cout<
|
|
|
|
|
The problem is using MFC in a console application. By default, the MFC socket classes need a
window to process socket events. You could get it to work with the proper MFC initialization in a console app but I'm not sure it's worth the trouble unless you're using other MFC classes.
You could try using direct calls to WinSock instead of using the MFC classes.
If you must use MFC then can you post the code used to initialize MFC?
Mark
|
|
|
|
|
Hi
I think your code have to work. Only a question, Have you create the console app with MFC options?
David Leyva
|
|
|
|
|
Clarification for David's question - Have you create the console app with MFC options?
MFC options mean In the preferences I set the option "Use MFC as a shared DLL". Is that you mean or some thing else? Alse the variable s is of type CSocket. Other than the above mentioned code I did not write any thing extra (Except declarations). l is a character array of size 20 and n is an int type. s,t are variables of type CSocket.
For Mark:
---------
I did not write any code related to MFC initialization. Please tell me what is that code to initialize MFC in a console based application. Also, Please mail me how to attach my code to a window in a console based application without that window to be displayed. I did not understand the statement "MFC socket classes need a window to process socket events". Did not understand means How to simulate that is thing I did not understand.
Srikanth K
|
|
|
|
|
Does your app have a main() function or WinMain()?
If so, get rid of that and set the programs entry point (in linker options) to
wWinMainCRTStartup.
If you are using MFC then MFC handles the entry point for you and initializes itself.
As with any normal MFC app you'll need ONE global static object of a class dervived from CWinApp.
Override InitInstance() in this class and perform initialization there, including initializing
Windows Sockets with WSAStartup(). You don't need to create a main window for the app since it's
a console app.
|
|
|
|
|
Hi Srikanth,
Also make sure you hit reply on my messages if you want me to see your replies.
It was just by chance I looked this far into old messages and saw that you had replied
Mark
|
|
|
|
|
Hi,
does anyone know a trick how to get the ideal size for the CDateTimeCtrl to display all of its content in all formats it supports?
It doesn't resize itself to a proper size for its content and it seems it has alot of internal logic for sizing the various internal edit fields.
A simple GetWindowText() and GetOutputTextExent() doesn't work in all cases (i.e. when there are date/time formats set without leading zeros).
I know there is a special window message available on vista to fetch the ideal size of the CDateTimeCtrl, but what to do in previous windows versions ?
Many thanks,
Watz
|
|
|
|
|
You see, I'm not sure I really need a fully featured tabular control. I'm doing a fairly simple dialog based application using the AppWizard in VC++, which will load some ascii text files and display them in a table format. At some point in the future RS232 will read in new values but for now, it will be a case of editing a few edit controls and clicking a button to "push" a line of data into the table, comparing and doing some calculations on the way. I don't see that there'll be much need for the users to interact with the table other than I'd like at some point to be able to push that out to a print option
Is there an easy way to do this? I probably only need pointing in the right direction to start with.
t.i.a
Lee
|
|
|
|
|
|
thanks. I've not done a lot with VC++ for a while, and didn't correlate "List control" with "tabular data" when I saw that in the controls palette
|
|
|
|
|
Hello All,
I added a Rich Edit Box to my dialog and executed the dialog now the problem is dialog is not getting displayed & no action is performed or any error is displaed.
Guys can u please tell me hw to add a Rich Edit Control to my Dialog using Win32 App. ???
Thanking you,
Suresh HC
|
|
|
|
|
You need to call AfxInitRichEdit to initialize rich edit control for app.
Call this function in your application.
|
|
|
|