|
Probably not a bug in the compiler.
Usually problems like this are the result of header files not matching the code that is being pulled in from a library--like the header files have been updated and the library not recompiled, or building with debug on and linking with non-debug libraries.
|
|
|
|
|
I'm using Visual C++ 6.0
I'm trying to creat a small Inventory program to keep track of my CD sales
First I want to create a file called cd1.txt and be able to update it with the following:
Total Onhand
60
Then each time someone clicks on the OnRadio1 substract from the Total OnHand.
Total Ordered
10
Total OnHand
50
Once the Total OnHand gets below 20 dislpay a message box to tell me to I need to update the cd1.txt file. I should then be able to add to total OnHand
for a new total.
This is what I have so far. And It doesn't seem to work. Could someone get me started on the right track?
void CCdInventoryDlg::OnRadio1()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
FILE*cd1;
char buffer[81];
int i,ch ;
cd1 = fopen("cd1.txt","a+"); //create cd1 text file
ch = fgetc(cd1);
for(i=0; (i < 80) && ( feof(cd1) == 0); i++)
{
buffer[i] = (char)ch;
ch = fgetc( cd1 );
}
/* Add null to end string */
buffer[i] = '\0';
fprintf(cd1, "%d", buffer );
fclose( cd1 );
}
|
|
|
|
|
Not to sound rude but why do you want to use a text file? I would suggest that you either use an .ini file or store those three entries in the registry. That way, you won't have to worry about reading from a text file, parsing the strings, checking for errors, updating them etc.
mike.beck wrote:
And It doesn't seem to work
What is it that doesn't work? In your fprintf statement, you are trying %d and that works for decimals. You might not be printing what you want to print.
// Afterall, I realized that even my comment lines have bugs
If the sun were to blow up, it would take us 7-8 minutes to realize it.
|
|
|
|
|
Hi Toni78,
It doesn't sound rude... I just need to create a simple inventory program for my cd's....And I guess I really don't know what to do....
|
|
|
|
|
As I said earlier, you can use an ini file or the registry. Check MSDN for references because it will be very helpful.
// Afterall, I realized that even my comment lines have bugs
If the sun were to blow up, it would take us 7-8 minutes to realize it.
|
|
|
|
|
If you could settle for an INI file in the following format, it'd be much simpler:
[Inventory]
TotalOrdered=10
TotalOnHand=50
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
If you are not well versed in INI files, take a look at
CWinApp::WriteProfileString();
CWinApp::WriteProfileInt();
CWinApp::GetProfileString();
CWinApp::GetProfileInt();
Peter Molnar
|
|
|
|
|
Is there any way in C# or other languages to detect the dependent DLLs of an existing non-DotNET DLL (regular DLL)? For i.e. if XXXX.DLL is using AA.DLL and BB.DLL, the last two DLLs are detected by the small piece of code after passing XXXX.DLL name.
Thank you.
Arash Sabet
Computer Engineer
E-mail: afifi@sympatico.ca
|
|
|
|
|
You can analyze dependency list by reading import table from PE file.
Matt Pietrek had an article and source in MSJournal, Feb 1997.
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
I just tried to build a simple program like Hello.cpp by using Visual C++. NET but I got errors for Linking problem. Anyone has any idea how to set it up correctly?
|
|
|
|
|
What kind of liking problems did you get?
// Afterall, I realized that even my comment lines have bugs
If the sun were to blow up, it would take us 7-8 minutes to realize it.
|
|
|
|
|
When i pressed build and it gave me this error
error LNK2019: unresolved external symbol _WinMain@16 referenced in function _WinMainCRTStartup
fatal error LNK1120: 1 unresolved externals
this is my code
#include <iostream>
using std::cout;
using std::endl;
int main()
{
cout << "Hello" << endl;
return 0;
}
|
|
|
|
|
This link error is occuring because your compiler/linker settings are expecting WinMain(...) as the entry function, not main(). This occurred when creating the project.
You can get the above code to compile by manually setting the compiler/linker settings:
- Make sure your "Solution Explorer is visible" ( View | Solution Explorer)
- Right click on project (**not the solution**) node in Solution Explorer tree view and select properties
- Click on C/C++ | Preprocessor. On the right hand side you will see "Preproccesor Definitions".
- Replace _WINDOWS with _CONSOLE (NOTE the underscore)
- Now, click on Linker | System. Click on the "Subsystem" on the right. Once the Subsystem line is active and drop down arrow appears to the far right. Click on that and you will see a list of choices. You want to change the "Windows (/SUBSYSTEM:WINDOWS)" to "Console (/SUBSYSTEM:CONSOLE)".
- Compile. Should work. Now "int main()" is the expected entry function.
The above can all be avoided by selecting a "Win32 Console Project" instead of a "Win32 Project" when you create a new project.
And by the way, I am assuming your iostream header was included and was clipped from your code above because the "< >" was treated as an HTML tag in the post.
Mike
|
|
|
|
|
Thanks Mike...i solved my problems by choosing Console Project.
|
|
|
|
|
Hi!
I am looking for a C++ compiler for AMD64 platform, preferrably a free version!
Does GNU GCC work for me? They do not explicitly say that it produce AMD x86-64 code!
Thanks in advance!
Rob
|
|
|
|
|
Yes.
gcc -m64
Maxwell Chen
|
|
|
|
|
My app uses an old style MFC File open dialog box.
I noticed that in Microsoft Word - File Open dialog box, if you click the drop down box for the "Look in" field at the top, there is an option at the bottom that says FTP Locations.
One can use this option to open files from a remote location via FTP directly into MS Word.
I need this ability in my app but I can't figure out how. I have looked through the MFC documentation and I can't find squat!
Any help appreciated.
George W
Software Developer
www.zsystems.ca
|
|
|
|
|
|
Hi,
I am creating a CListCtrl component, with the style "owner draw fixed" on. I'm catching the WM_CONTEXTMENU message in order to recognize right-click on the list control, and then I use HitTest
function to look if the mouse is on one of the items.
I find that I get return value 0 even if my mouse is on the header
row. I use ScreenToClient function previous to calling HitTest.
How can I recognize that I'm on the header row ?
Many many thanks in advance to anyone of who has an idea.
g_sol_1
|
|
|
|
|
Before doing the HiTest call, can you do a WindowFromPoint() and see whether it returns the GetHeaderCtrl() CWnd* pointer or the CLIstCtrl pointer, as the header should be a different child window of the main control.
Roger Allen - Sonork 100.10016
If your dead and reading this, then you have no life!
|
|
|
|
|
Thanks Roger for your prompt reply !
Your solution works great, but I'm trying also different approach
to my problem, here is another question in this area:
Is it possible to catch the ContextMenu event when it is fired from the header control so it will not pass on to the list control ?
If you or anyone else knows the answer and has some time to reply, It will be great.
Thanks again, Gidi Gal
|
|
|
|
|
This function is not being nice to me! Here's what I have:
KeyInfo.h:
class CKeyInfo : public CObject
{
public:
CKeyInfo() {}
virtual ~CKeyInfo() {}
DECLARE_SERIAL(CKeyInfo)
virtual void Serialize( CArchive &ar );
};
KeyInfo.cpp:
IMPLEMENT_SERIAL(CKeyInfo, CObject, 1)
void CKeyInfo::Serialize( CArchive &ar )
{
CObject::Serialize(ar);
if (ar.IsStoring())
{
}
else
{
}
}
MyDoc.h:
class CMyDoc : public CDocument
{
...
private:
CArray<CKeyInfo *, CKeyInfo *> m_arrKeyNames;
};
MyDoc.cpp:
void CMyDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
}
else
{
}
m_arrKeyNames.Serialize(ar);
}
I've tried placing this function in several places, all to no avail. I've also tried it with several different signatures (e.g., Internet examples, MSDN). It never gets called. The default implementation (in afxtempl.h) does, though.
template <>
void AFXAPI SerializeElements <CKeyInfo> ( CArchive &ar, CKeyInfo *pKeyInfo, int nCount )
{
for (int x = 0; x < nCount; x++, pKeyInfo++)
pKeyInfo->Serialize(ar);
}
Anyone see what I might be doing wrong?
Thanks,
DC
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
hey,
what do i have to do to run my process in the LocalSystem Contex ?
Thanks in advance!
|
|
|
|
|
Hi,
I want to retrieve the CONNECTED computer names of a network. I want to avoid giving users the ability to submit their own 'server string', therefore i want to somehow retrieve the computer names of a network and place them in a tree view. It should look the same as, for example, the Window Explorer, only you won't be able to 'go deeper' into the hierachy (like folders etc.). I hope you understand what i'm trying to say......anyway....all help is appriciated.
Many thanks,
Abebe
Er zit een korstje op mijn aars.
|
|
|
|
|
I think you are looking for WNetOpenEnum() and WNetEnumResource() .
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|