|
I am trying to send a file to the server but the code is giving the following error:
Error on InternetWriteFile 12031
Please help me with this problem
Thanks In Advance
modified on Wednesday, October 22, 2008 2:10 AM
|
|
|
|
|
Hi All
I have a text file "New.txt".which have some data like this
ab
ac
ad
ab
ad
ac
Now i want to remove duplicate string(ab,ac and ad) from file.Can any one give me tips.
Plz help me
|
|
|
|
|
Use linked lists, either from the STL or of your own making.
Open File, read each line into a new list item.
Go through the list, remove any list items that match the current item.
Save the list items one-by-one back into a new file.
Or
Open file, read file line by line - doing nothing other than counting the number of lines.
Create an array with this many pointers to a string
Reset file pointer
For each line in file:
read line,
determine length,
allocate mem and store pointer in lineArray[currentLine],
copy string to this memory.
For each item in the lineArray
do a strcmp on all items that follow
if the strings match, free the memory of the matching line, and set it's pointer to NULL
For each item in the line Array
if the pointer isn't NULL, it contains a unique string.
If the pointer is NULL, the string wasn't unique and has been removed.
either print or save to file all of the valid strings remaining in the array
For each item in the array
free the used memory (free won't fail on a NULL pointer)
|
|
|
|
|
You can use a std::set for that. Read each line and insert it into your set. If the value is already present in the set, it won't be added a second time.
|
|
|
|
|
That sounds good, but could you extract the entries in the order [*] they were put in? He didn't say whether he cares or not, but I would - minimum changes needed to meet the spec, etc.
Iain.
[*] Genuine question. Not an expert on the std::collections.
|
|
|
|
|
No I don't think so, the set sort the entries. You're right, I didn't think about this, I only thought that he wanted to get rid of the duplicates.
|
|
|
|
|
Cedric Moonen wrote: the set sort the entries.
If I'm not mistaking, if you want it unsorted you should use hash_set, which is located in the stdext namespace
std::map and std::set are sorted
stdext::hasp_map and stdext::hash_set are the unsorted counterparts.
Learn from the mistakes of others, you may not live long enough to make them all yourself.
|
|
|
|
|
Hi,
In my applicationim using ine structure and im storing the values of variables each second.
But the size of structure is very high,the filesize is getting increased each second.
My strucutre is
struct ReplayTags //CD07
{
float SPV [900];
float CSV1 [900];
float CVOUT [900];
float CNTP [900];
float CNTI [900];
float CNTD [900];
....
....
char AMCAS [100];
}
I have to write the value of all variables like SPV,CSV1..in to file each second.
But definetly i can say tht im not using whole 900 SPV values etc.,..sometimes it vary from 100 to 200 like tht only.Its dynamic...depends upon my applcaiton it may vary every time..
But i know how many variables are used in tht application.i can get tht by using one variable of count of SPV.
My question how i declare the variable size as dynamic.
I dnt know how to do it.
WriteFile( htReplayFile, temp,(DWORD)sizeof(struct ReplayTags), (LPDWORD)&ReturnVal, (LPOVERLAPPED)NULL );
THis is code used to write in files,Here im using size of Struct.
Pls help me..
Anu
|
|
|
|
|
You should be able to serialize that structure much more efficiently.
Even writing a count WORD follwed by the floats for each array would
be a huge improvement
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi friends,
I have encountered a problem that I would like to ask you.
I have a Main-Dialog and a child dialog. The child dialog is
hidden and I would like to find it at run time. I use several
APIs such as FindWindow but it is not usefull to me (Since my
child dialog has no caption) and also, EnumWindows and EnumChildWindows,
but apparently these APIs can not find child dialogs.
I put my code here to clarify my solution. Thanks very much in advance.
in the code :
EnumChildWindows(m_hWnd, EnumChildProc, NULL);
/************************************************************************/
BOOL MyDlg::EnumChildProc(HWND hwnd, LPARAM lParam)
{
// Access to the ECDialog members through pThis.
CCMDDlg* pThis = (CCMDDlg*)lParam;
//GetDlgCtrlID()
if ( IDD_CHILD_DLG == FromHandle(hwnd)->GetDlgCtrlID() )
{
// Find Child Dialog
Beep(1000, 500);
return FALSE;
}
return TRUE;
}
/************************************************************************/
BOOL MyDlg::EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
int i = CWnd::FromHandle(hwnd)->GetDlgCtrlID();
if ( IDC_CHILD_DLG == FromHandle(hwnd)->GetDlgCtrlID() )
{
Beep(1000, 2000);
return FALSE;
}
return TRUE;
}
/************************************************************************/
|
|
|
|
|
EnumChildWindows, will enumare only the windows which is creare with WS_CHILD style. I think the only possiblity method for you to use is EnumThreadWindows .
Mohammad Khodaea wrote: if ( IDC_CHILD_DLG == FromHandle(hwnd)->GetDlgCtrlID() )
This technique wont work. Because the ctrl id of dialogs is always 0. The IDC_CHILD_DLG is only used to identify the dialog in the resource.
|
|
|
|
|
Hi all,
Unhandled exception at 0x762c42eb in Test.exe: Microsoft C++ exception: CDBException at memory location 0x001236fc..
occur when i use Open statement for data base.
I m using CRecordset derived classes for database.
When i m using Open(); than this error occurs.
please help me for this.
thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
There should be specific info in the exception object. CDBException has a return code
and two error strings - what's in there?
It's a really good idea to handle the documented exceptions
thrown by the MFC database classes, unless you prefer your apps
to just terminate abnormally, of course
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
It returns -1.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
"_$h@nky_" wrote: It returns -1
What does?
What kind of database are you connecting to?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I m using a Access database with ODBC connesction.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
And -1 is all that's in the thrown exception object? No strings?
I know SQL server returns pretty useful error strings that are placed
in the CDBExceptions....not sure about Access.
You can always step into the Open() call and see where it's failing.
There's lots of potential reasons...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Now its resolveed,
Thanks sir
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Hello,
Pardon me, its a pure question of C/C++ not specific to Visual C++. Can anybody explain what is the purpose of following code:
void Function1(int a, int b)
{
void Function2(int c, int d, int e); // in some header file
void Function3(int c, int d, int e); // in some header file
int i, k, l;
//rest of the code in which Function2 and Function3 are being used!
}
I have no idea why "Function2" & "Function3" prototypes are defined in the function named "Function1", and is it possible? If yes whats the logic behind it?
Any help is highly appreciated.
Regards,
Adeel
Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.
|
|
|
|
|
This is just a function declaration. Its purpose is to tell the compiler that in some other place( may be in another file or in the same file ) we have a function defined with name Function2 and Function3 with following prototype. Other wise the compiler will thow compilation error saying the Function2 and Function3 cannot be found.
|
|
|
|
|
That means, logically it is equal to:
void Function2(int c, int d, int e);
void Function3(int c, int d, int e);
void Function1(int a, int b)
{
//actual code
}
Right?
Regards,
Adeel
Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.
|
|
|
|
|
Ya almost. But the difference is that, now all the functions after the Function1 will be aware of the Function2 and Function3.
If the declation was inside the Function1, only Function1 will be aware of the Function2 and Function3. Trying to call those functions from any other function will create compilation error. That is the scope of the declaration is restricted to the body of Function1.
|
|
|
|
|
I am using following libraries to calculate MAC address and IP address. when i run my program it works fine but when i makes its setup and install on such system wher VC is not install then program does not run it just generate exaption and no output. before adding work of calculation of MAC my set was working properly
library files are
ws2_32.lib
snmpapi.lib
inetmib1.dll
in inosetup i am including these like
Source: "C:\windows\system32\ws2_32.DLL"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\windows\system32\snmpapi.DLL"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\inetmib1.DLL"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\Program Files\Microsoft Visual Studio\VC98\Lib\ws2_32.lib"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\Program Files\Microsoft Visual Studio\VC98\Lib\snmpapi.lib"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
|
|
|
|
|
Look for Microsoft redistributables (libraries that come with the compiler that are needed to make programs function corectly). These are freely redistributable hence the name. Get the ones that go with the compiler you are using.
|
|
|
|
|
can any tell me what is the difference between c# and c++ structs..
Santhapur
|
|
|
|