|
Hi,
You can use the INI file to read/write the information needed by application.
You can read IP address into a string, and port number into an integer variable and use these variable to call initialization functions.
An article here: How to read and write an INI File[^]
Thanks,
Suman
--
"Programming is an art that fights back!"
modified on Saturday, April 5, 2008 9:23 PM
|
|
|
|
|
hi!,
i tried INI file read and write but VS C++ does not support afxwin.h. SO is there another way to go about it. Anyways i am trying on this but if u have some other option maybe i can try tht out.
thanks
|
|
|
|
|
Hi,
Are you using Express version of vc++?
If its Express version, there will be no MFC.
afxwin.h is MFC's file.
Thanks,
Suman
--
"Programming is an art that fights back!"
|
|
|
|
|
HI,
yes i am using express version so now whats do you think i should do?
|
|
|
|
|
Hi,
Check are you able to use C's standard file handling something
like:
<br />
FILE *pFile;<br />
pFile = fopen("SETTINGS.TXT", "r");<br />
Take a look at here: Stream I/O[^]
Thanks,
Suman
--
"Programming is an art that fights back!"
modified on Saturday, April 5, 2008 11:14 PM
|
|
|
|
|
you don't need MFC to access a INI file, have a look at [^]
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
ADTC# wrote: I am doing a socket programming in c. The basic client server works fine.
*Amaze*
Read_file----->string x--->inet_addr(x)
Read_file---->string x--->htons(atoi(x))
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
ADTC# wrote: The basic client server works fine
If you are able to do basic client server then I am pretty much sure that you would be able to do basic file and string IO. So following basic things you can do.
1. Have your IP address and port number in a standard text file
The format can be like this
IP ADDRESS : 127.0.0.1
PORT NUMBER : 1234
2. Read the file line by line using standard file IO and store them in two strings
3. Split the strings by ":" token. Now you have IP address and port number in two of the four strings.
Hope this helps.
"Give a man a fire and he's warm for a day, set a man on fire and he won't feel cold for the rest of his life."
|
|
|
|
|
i would like to create a windows form application which captures the keyboard inputs.
Can someone tell me the best and easiest method?
thanks...
|
|
|
|
|
Do you mean Windows Forms in .NET or a dialog form?
For forms in .NET, you'r on the wrong discussion board - use the Managed C++/CLI board[^] instead.
Otherwise, any window in a Windows app that has the keyboard focus will receive WM_KEYDOWN and WM_KEYUP
messages, and also WM_CHAR messages if TranslateMessage is caled in the app/thread's message loop.
If you want to catch keyboard input system-wide, you can use a hook. See SetWindowsHookEx[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i got my answer
it is helpfull
thanx...
--we were great,and we will rise again--
--------Don't forget--------------------
--always comes daylight after night-----
|
|
|
|
|
Hi every body!
I used the following connectioin string to connect to a MS Access database:
<br />
"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=FilePath;PWD=Password;"<br />
Every thing went fine unless I tried to close the app; The following error code appeared:
"The instruction at "0x000faf" referenced to memory at "0x00faafe". Memory could not be "read". Click OK to terminate the program."
Next I added the following expresion to connection string:
"MaxBufferSize=2048;
And my problem disappeared.
Why?
|
|
|
|
|
It's still up to you to find out what's going on.
You said it happens just opening and closing the database - in that case, there's not a whole
lot of code to step through
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Dear all,
How to read the values, which are separated by tab, inside a txt file into an array?
Thank you,
John
|
|
|
|
|
Read the words one by one.
Place them into the array one by one as you read.
Regards,
strtok.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
CStringArray straYourArray;<br />
CString strArrayElement=_T("");<br />
CFile file(_T("YourFilePath"), CFile::modeRead);<br />
ULONG uSize=file.GetLength();<br />
ULONG uToken=0;<br />
BYTE *Buffer=new BYTE[uSize]={0};<br />
<br />
file.Read(Buffer, uSize);<br />
for(int iCountor=0; iCountor<usize; icountor++)<br />
{<br />
if(Buffer[iCountor]=='Tab ASCII Code')
{<br />
strArrayElement.SetString(Buffer, iCountor-uToken);<br />
straYourArray.Add(strArrayElement);<br />
uToken=iCountor;<br />
}<br />
}<br />
file.Close();<br />
Sorry for not to offer comments...
Any question?
modified on Saturday, April 5, 2008 10:32 PM
|
|
|
|
|
Usef Marzbani wrote: Any question?
Yes, why don't you check return values in your sample code?
BTW use <pre> tags around code snippets.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Because I'm not going to design MS Word in this forum
|
|
|
|
|
I don't know if the Office guys did, it is so buggy indeed...
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I hate MFCs.. [ read it in Brendan Fraser's tone.. I hate mummies..*gunshot* ]
<br />
ifstream ifs("E:\\test.txt",ios::in);<br />
string st; <br />
vector<string> vec_words;<br />
while (ifs>>st) <br />
{<br />
vec_words.push_back(st);<br />
}<br />
ifs.close();<br />
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
modified on Sunday, April 6, 2008 3:44 AM
|
|
|
|
|
VuNic wrote: I hate MFCs.. [ read it in Brendan Fraser's tone.. I hate mummies..*gunshot* ]
Me too.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Cheers! .. watch out! we might have scratched the MFC lord Mark Salsbery. I guess he loves it so much that he may even wish to call it :-
Mark's Favorite Classes.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
|
Yep in general,Mummies raise up from random locations and they are certainly not alone. And most of them look invincible most of the time.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
If I remember it right, a laaaawwng time ago, I read a similar solution to the same problem on a C++ book. I don't know, but I think it was that Bruce Eckel's book.
[Add] Confirmed that book. How amazing you remembered it right. Or, may be if you are working on plain C++, you must be doing it occasionally. [/ADD]
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
modified on Sunday, April 6, 2008 4:33 AM
|
|
|
|