|
Yes the code is ancient, everything seems reverse to me. as you suggested i commented second block.
#ifdef __STDC__
DWORD WINAPI process( LPVOID Var )
//#else
//DWORD WINAPI process( var)
// LPVOID var;
#endif
lot many errors are reduced, now what I get is:
xyz.cpp(46) : error C2447: '{' : missing function header (old-style formal list?)
xyz.cpp(46) : error C2447: '{' : missing function header (old-style formal list?)
xyz.cpp(46) : error C2447: '{' : missing function header (old-style formal list?)
xyz.cpp(46) : error C2059: syntax error : '}'
xyz.cpp(46) : error C2143: syntax error : missing ';' before '}'
xyz.cpp(196) : error C2059: syntax error : '}'
|
|
|
|
|
It should look like this:
DWORD WINAPI ZI_process_monitor( LPVOID TA_arg )
when __STDC__ is not defined.
Finally you should delete all commented lines.
|
|
|
|
|
Yes got it. absolutely.
Thanks a ton Jochen
|
|
|
|
|
my PQR.cpp file which was originally failing at ctype.h line#362 - #if !__STDC__
saying "Compiling...PQR.cpp include\ctype.h(362) : fatal error C1017: invalid integer constant expression
for which i went on to fix file xyz.cpp, xyz.cpp got fixed when i undid my __STDC__ related changes and applied your suggestions but the old one PQR.cpp is still breaking with same error at same location
I applied your suggestions to PQR.CPP (The real file and real error for which i started all this) also thinking that if XYZ.CPP works PQR.cpp also should work, I can finally get rid of ctype.h but NOOO
|
|
|
|
|
Was ctype.h included before or did you add it?
If you added it, remove the including.
If it was there, check the line with the failure in ctype.h. Check also if the failing code is guarded by some preprocessor definition. A common error would be that some type or definition used by ctype.h is improperly defined somewhere in your header files.
You may also move the including of ctype.h on top before inclduing any other file (except stdafx.h if used).
|
|
|
|
|
it all began with __STDC__. I took the VS6 codebase dump and started compiling for that
1) lots of tagVariant related to fix that i removed __STDC__ from project properties.
2) now i stared getting syntax related error in my .cpp and .c files in thousands.
3) to remove that I added __STDC__ locally in some of the files like xyz.cpp
4)Then most of the files compiled but PQR.cpp and ABC.cpp gave an error failure in ctype.h at line 362
5)then I contacted you
6) I learnt about __STDC__ more in detail and removed __STDC__ from my files where ever i had added it to fix syntax errors and did the proper code fix with your help.
7)I am again back ctype.h file error in PQR and ABC .cpp files.
I am trying what you are suggesting now...atleast that seems a right way to go...
|
|
|
|
|
Wow...I could compile the project. I do have lot of LINK errors but I will work on it.
I learnt this "Use precompiled headers - stdafx.h. This must be the first include in your .cpp file."
Changed the sequence of the .h files and I am all set now.
Thanks a TON Jochen...you are awesome !!
modified 30-Jul-14 5:14am.
|
|
|
|
|
Fine that you finally solved all compiling errors.
|
|
|
|
|
<blockquote class="quote"><div class="op">Quote:</div>#include<stdlib.h>
#include<stdio.h>
int main(int argc, char *argv[])
{
srand(12345);
float a = 5.0;
int i;
for (i=0;i<63530;i++)
printf("%f\n", ((float)rand()/(float)(RAND_MAX)) * a);
FILE *fout;
const char *text=("write this text to file");
fwrite(fout,((float)rand()/(float)(RAND_MAX)) * a,text);
return 0;
}</blockquote>
|
|
|
|
|
|
same problem no change
|
|
|
|
|
You must read the documentation and understand the type and meaning of the different parameters.
The fwrite function has four parameters but you are passing only three. Additionally, your parameters did not match the required types. The first parameter is a pointer to the binary data to be written. But you are passing the pointer to your FILE stream object. The second and third parameters specify the amount of data to be written and the last one is the FILE pointer.
To write a binary floating point value you might use:
float f = ((float)rand()/(float)(RAND_MAX)) * a;
fwrite(&f, sizeof(float), 1, fout);
To write data to a text file use fprintf like printf passing the FILE pointer as first parameter.
|
|
|
|
|
thank you finally I got it..
|
|
|
|
|
even though I pass fwrite(fout,((float)rand()/(float)(RAND_MAX)) *a,text);
it is generating the file.txt but null value on it..
|
|
|
|
|
#include"c:\turboc3\bin\header.cpp" /*i have created a file with all the header files*/
void main()
{
long num,num1,i=0,j=0,multiplier=1,sum=0,a[100];
clrscr();
cout<<"Enter the number:";
cin>>num;
num1=num;
while(num!=0)
{
num=num/10;
i++;
}
for(j=i;j>0;j--)
{ multiplier=pow(10,j);
a[j]=num/multiplier;
num=num-(a[j]*multiplier);
}
for(j=0;j<i;j++)
sum=sum+a[j];
cout<<"The sum of the digits of the "<<i<<" digits number "<<num1<<" is:"<<sum;
getch();
}
|
|
|
|
|
If you want to iterate the digits, then why get the number as a number rather than as a string?
I'd get the string, iterate the digits, then get the numeric value of each digit, and then sum them.
That makes getting the number of digits simpler as well.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Are you wanting a "digital root" algorithm?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
The 'quick fix' of your bugs produce the following program:
int main()
{
long num,num1,i=0,j=0,multiplier=1,sum=0,a[100];
cout<<"Enter the number:";
cin>>num;
num1=num;
while(num1!=0)
{
num1=num1/10;
i++;
}
num1 = num;
for(j=i-1;j>=0;j--)
{
multiplier=pow(10,j);
a[j]=num1/multiplier;
num1=num1-(a[j]*multiplier);
}
for(j=0;j<i;j++)
sum=sum+a[j];
cout<<"The sum of the digits of the "<<i<<" digits number "<<num<<" is:"<<sum << endl;
getchar();
}
However, I would rather write it this way:
int main()
{
long num, sum = 0;
cout<<"Enter the number:";
cin>>num;
while (num)
{
int remainder = num % 10;
sum += remainder;
num /= 10;
}
cout <<"The sum of the digits of is:" << sum << endl;
getchar();
}
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
modified 28-Jul-14 5:55am.
|
|
|
|
|
I'd like to remind you that you probably meant to write remainder , not reminder .
Good stuff though.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Stefan_Lang wrote: I'd like to remind you that you probably meant to write remainder , not reminder .
Thank you, fixed.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
Hi,
Don't use so many loops unnecessarly, here is the one way to get your answer in optimistic way.
int main()
{
long num,num1,i=0,sum=0;
short remainder = 0;
cout<<"Enter the number:";
cin>>num;
num1=num;
while(num!=0)
{
remainder = num % 10;
num = num / 10;
sum = sum + remainder;
i++;
}
cout<<"The sum of the digits of the "<
|
|
|
|
|
This method does not work:
lvi.mask = LVIF_TEXT;
lvi.pszText = "one";
m_ListCtrl.InsertItem(&lvi);
lvi.pszText = "two";
lvi.iSubItem = 1;
m_ListCtrl.InsertItem(&lvi);
This method does not work:
for (int nI = 0; nI < m_strarrayOtherImgFiles.GetCount(); nI++)
{
pOtherImgsList->SetItemText(nI, 0, m_strarrayOtherImgFiles.GetAt(nI));
}
Nothing seems to work.
|
|
|
|
|
Hello,
First, see the topic - 'How to ask Questions' in this forum.
Second, you are missing lvi.iItem I think. Try adding this and see.
lvi.mask = LVIF_TEXT;
lvi.iItem = 0;
lvi.iSubItem = 0;
lvi.pszText = "one";
m_ListCtrl.InsertItem(&lvi);
lvi.pszText = "two";
lvi.iSubItem = 1;
m_ListCtrl.InsertItem(&lvi);
Regards,
A. Gopinath.
|
|
|
|
|
|
I have been reading the documentation - where else do you think I obtained those methods that I have been trying.
This is what I have tried precisely.
And function
int InsertItem(
int nItem,
LPCTSTR lpszItem
,as described here (http://msdn.microsoft.com/en-us/library/8b9s12fc.aspx[^]), DOES NOT WORK The function does nothing. WHY?
Can you only add items to a CListCtrl via
int InsertItem(
const LVITEM* pItem
); and the function that I have been using is in fact defunct?
void CImageDialog::DDX_List(CDataExchange* pDX, UINT uListCtrlID, CStringArray& rarrayOtherImgFiles)
{
CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(uListCtrlID);
int nI = 0;
CString strItem;
ASSERT_VALID(pListCtrl);
if (pDX->m_bSaveAndValidate)
{
m_arrayOtherImageFiles.RemoveAll();
for (nI = 0; nI < pListCtrl->GetItemCount(); nI++)
{
strItem = pListCtrl->GetItemText(nI, 0);
m_arrayOtherImageFiles.Add(strItem);
}
}
else
{
pListCtrl->DeleteAllItems();
for (nI = m_arrayOtherImageFiles.GetCount() - 1; nI >= 0; nI--)
{
pListCtrl->InsertItem(1, m_arrayOtherImageFiles.GetAt(nI));
}
}
}
void CImageDialog::DoDataExchange(CDataExchange* pDX)
{
CMyDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT_HEADER_IMG, m_strHeaderImageFile);
DDX_Text(pDX, IDC_EDIT_NAV_IMG1, m_strNavImg1File);
DDX_Text(pDX, IDC_EDIT_NAV_IMG2, m_strNavImg2File);
DDX_Text(pDX, IDC_EDIT_OTHER_IMG_FILES, m_strOtherImgFiles);
DDX_List(pDX, IDC_LIST_OTHER_IMG_FILES, m_arrayOtherImageFiles);
}
|
|
|
|