|
It points to a BITMAPINFOHEADER structure.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Can we test (unit test) C++ (not VC++) project using VC++ Unit Test project.
More details: I have a project written in C++ (standard). Now i want to test it.
I create a VC++ Unit Test project, but i can not make link between this Test project with my C++ project (can not call functions (defined in my C++ project) in test methods)).
Hope some one can help me.
Thank you.
LC
|
|
|
|
|
Hi all,
LPCSTR data;
CString m_FName;
CString strFName = m_FName + data;
When i write this piece of code it works fine in vc++ 6.0 compiler. But when i write this in VC 2005 it gives error:-
" error C2679: binary '+' : no operator found which takes a right-hand operand of type 'LPCSTR' (or there is no acceptable conversion)"
How to resolve this....
Thanks in advance........
|
|
|
|
|
CString strFName = m_FName + CString(data);
|
|
|
|
|
now next error is
FILE* fp = fopen(strFName,"wb");
error C2664: 'fopen' : cannot convert parameter 1 from 'CString' to 'const char *'
|
|
|
|
|
Probably you need
FILE * fp = _tfopen(strFNAME, _T("wb"));
or to choose an ANSI build.
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.
|
|
|
|
|
No it gives same error..........
|
|
|
|
|
CPallini wrote: FILE * fp = _tfopen(strFNAME, _T("wb"));
The compiler was complaining about the first argument.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I know.
Probably he is making a UNICODE build with code previously built as ANSI. Now CString 's LPCTSTR cast operator turns out to be LPCWSTR . The suggested use of _tfopen fixes that problem (using a generic text mapping approach) but then we need to be consistent and use also _T() on the second argument.
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.
|
|
|
|
|
FILE* fp = fopen((LPCTSTR)strFName,"wb");
|
|
|
|
|
after doing this
error C2664: 'fopen' : cannot convert parameter 1 from 'LPCTSTR' to 'const char *'
|
|
|
|
|
impossible.
post a relevant piece of code please.
|
|
|
|
|
toxcct wrote: impossible.
Yes, if UNICODE is defined.
|
|
|
|
|
CString strFName = m_FName + CString(data);
FILE* fp = fopen((LPCTSTR)strFName,"wb");
Its giving error
error C2664: 'fopen' : cannot convert parameter 1 from 'LPCTSTR' to 'const char *'
|
|
|
|
|
Use _tfopen() instead.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hiya guys i seem to have this rather annoying problem, i'm trying to finish a 9 question assignment on C, however i have managed to finish 7 of those but am stuck on two of them. I tried finding hints/tips on the internet as well as try to understand the topic from library books but i still can't seem to understand the whole thing. Anyways i stumbled upon this site and i really need your help. If anyone can solve these two questions for me i would really appreciate it.
1- The day of the week for any given date can be calculated using Zeller's congruence, which can be neatly programmed into a computer. The technique is detailed below.
Assume that "year", "month" and "day" have been given as three integers, for example 1965, 8, 23 respectively for August 23rd 1965. The calculation continues.
if month < 3 then
month=month+12
year=year-1
end if
Then
nd=((13*month+3)\5+day+year+year\4-year\100+year\400)mod 7
The sign \ is used to indicate integer division (ignore the remainder) – to achieve the desired result simply use integers for everything (some languages, C not being one, actually have an ‘integer devision’ method). The "mod 7" terms means find the remainder after dividing by 7. Note: in C Mod is calculated in C using the ‘%’ , ie 16%8 is 16 mod 8 = 0
The result, nd, gives the day: 0 is Monday 1 is Tuesday etc. T
he formula is (of course!) year 2000 compliant, but only extends back to the Gregorian calendar revision, which occurred at different dates in different countries.
Ask the user to enter the day, month & year then, calculate ‘nd’ and then use this value in a switch statement where the ‘cases’ are enumerated variables defined for the days to display the relevant day of the week.
2- Unions:
You are required to create a union containing the various integer and float types and an array of unsigned chars.
The size of the array of chars should be the number of bytes used for storage of the largest variable type
Assign values to the various members of the union and then display the values of the bytes used for storage.
Extend the program from part 1 such that the bytes are displayed using a single function which is passed your union & the no of bytes for the type assigned.
Using your union from above ask the user to enter an integer value. Display the bytes used for storage.
Swap the bytes used in storage and then display the new byte sequence and the ‘new’ integer value. You should do this for ALL integer types > one byte in size.
Once again if anyone could help me with this i would really appreciate it, and i look forward to hearing from anyone soon. Thanx a lot.
Hayan
|
|
|
|
|
Answer to your first Question::
int day = 12, month = 1, year = 1984;<br />
<br />
if(month < 3)<br />
{<br />
month = month + 12;<br />
year = year - 1;<br />
}<br />
<br />
int nd = ((13 * month + 3) / 5 + day + year + year / 4 - year / 100 + year / 400) % 7;
now use nd as you want it will contain 0 to 6 for Monday, Tuesday,...,Sunday
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
I am not getting your second question.
Explain it again in brief
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
3alawii wrote: If anyone can solve these two questions for me i would really appreciate it.
So what are your questions?
3alawii wrote: if month < 3 then
month=month+12
year=year-1
end if
Hint: January and February are counted as month 13 and 14 of the previous year.
3alawii wrote: The sign \ is used to indicate integer division
Not in C/C++.
3alawii wrote: 2- Unions:
You are required to create a union containing the various integer and float types and an array of unsigned chars.
The size of the array of chars should be the number of bytes used for storage of the largest variable type
Assign values to the various members of the union and then display the values of the bytes used for storage.
See here.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
This should get you on the way for your second question:
the union:
union AllTypes
{
signed short ssData;
unsigned short usData;
signed long slData;
unsigned long ulData;
float flData;
double dblData;
unsigned char ucData[8];
};
the display function:
void doPrint(unsigned char* pData, size_t tCount)
{
printf("data: ");
for(size_t tFoo = 0; tFoo < tCount; ++tFoo)
{
printf("%d ", pData[tFoo]);
}
printf("\n");
}
the Swap funtions:
void doShortSwap(unsigned short* pData)
{
unsigned short usTemp = 0xFF & *pData;
usTemp <<= 8;
*pData >>= 8;
*pData |= usTemp;
}
void doLongSwap(unsigned long* pData)
{
unsigned long ulTemp = 0xFFFF & *pData;
doShortSwap((unsigned short*)&ulTemp);
ulTemp <<= 16;
*pData >>= 16;
doShortSwap((unsigned short*)pData);
*pData |= ulTemp;
}
and an simple example:
<code>int main()
{
AllTypes var1;
var1.ulData = 12345687;
doPrint(var1.ucData, sizeof(AllTypes));
doLongSwap(&var1.ulData);
doPrint(var1.ucData, sizeof(AllTypes));
return 0;
}</code>
codito ergo sum
|
|
|
|
|
Hi Experts,
What it means by \\.\C:
I am using this to open a logical drive c: with CreateFile() API. What does mean by \\.\
|
|
|
|
|
a path starting by \\ is the UNC path to a computer. you can tell the PC's IP (like \\10.45.147.12 ), its UNC Name (like \\MyComputerName ) or the syntax that Windows API understand too, which points to the current machine (i.e. \\. ).
then, you point to a logical drive or share...
|
|
|
|
|
I understand what you say but... can you expand "UNC"? I don't know that acronyms
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
|
You are right, I should have looked for. I thought it was something like IMO, ROFL or another english shortcut. Sorry
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|