|
concomarx wrote: I want to write c++ program that converts distance entered in metre (input) to be converted to feet and inches and vice versa the program should use classes
The big deal, my dear, is to fit all the above calculations in few classes...
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.
|
|
|
|
|
I've tried it gives me funny errors, hows that got another way maybe am doing it badly
tick tock tick tock programming tick tocks...
|
|
|
|
|
Try to post your code..
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.
|
|
|
|
|
concomarx wrote: I've tried it gives me funny errors...
Errors aren't funny, they are serious.
concomarx wrote: ...maybe am doing it badly
How could we possibly know if you don't show us what you've tried?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
1 meter = 39,370079 inch = 3,28084 foot
1 inch = 0,083333 foot = 0,0254 meter
1 foot = 0,3048 meter = 12 inches
Hope it helps
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
|
|
|
|
|
concomarx wrote: tick tock tick tock programming tick tocks...
MATLAB-Programmer?
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
jhwurmbach wrote: MATLAB-Programmer?
humm c++ programmer
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
tick and tock are the timing functions in MATLAB-script.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
tick and tock are the timing functions in MATLAB-script.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Here is the declaration statement.
unsigned char *String;
Now i have made String point to "{abcdef}".
Here i need to delete the paranthesis, i.e, i need to delete the first and last character in 'String'.
How to make it point to a val of just "abcdef" without the first and last character??
Kindly help!
Priya Sundar
|
|
|
|
|
are you using MFC?
i.e. CString
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
chandu004 wrote: are you using MFC?
the OP specified explicitely that he was using a unsigned char *String .
so 1) read the questions
and 2) before giving advices to the forum members, stick to the rules yourself
|
|
|
|
|
so 1) read the questions
and 2) before giving advices to the forum members, stick to the rules yourself
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
Thanks for your concern.
Yes i use MFC.
By your question, I got an idea to convert it into a CString and apply delete and then save it back - something like this;
<br />
unsigned char *String;<br />
<br />
CString cString,result;<br />
cString="{abcdef}";<br />
int n=cString.GetLength();<br />
result=cString.Mid(1,n-2);<br />
<br />
String = (BSTR)rest; <br />
However, here i am not able to store it back to 'String'. i am getting various compiler errors like
" error C2440: 'type cast' : cannot convert from 'class CString' to 'unsigned short *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called "
Need help in typecasting in the last line.
Priya Sundar
|
|
|
|
|
What is rest , and why are you trying to cast it into a BSTR , when what you wand is a unsigned char* ?
And why unsigned char ? Thats uncommon.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
|
You want to convert a GUID to a String?
Try somthing like this:
void GetFormattedGuid( const GUID& guid, CString& rString)
{
const CString strFormat(_T("%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X"));
rString.Format(strFormat,
guid.Data1, guid.Data2, guid.Data3,
guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3],
guid.Data4[4], guid.Data4[5], guid.Data4[6], m_guid.Data4[7],
);
} When you are using MFC anyway, there is no point in not using it to help you.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Sorry, i want to convert a character array to GUID
<br />
bool CTcpIpPropertiesChangerApp::UUidConversion()<br />
{<br />
char szValue[MAX_GUID_STRING_LEN];<br />
<br />
szValue={A89377EA-D4ED-4A03-A37F-4A9DE785E1A9};
<br />
unsigned char *GuidString=new unsigned char[MAX_GUID_STRING_LEN];<br />
GuidString[MAX_GUID_STRING_LEN - 2] = _T('\0');<br />
<br />
for(int l=0;l<MAX_GUID_STRING_LEN;l++)<br />
GuidString[l] = szValue[l];<br />
<br />
GUID ret = { 0 };
if(UuidFromString(GuidString,&ret)==RPC_S_OK)<br />
{<br />
delete GuidString;<br />
return true;<br />
}<br />
else<br />
return false;<br />
}<br />
Now this function is always returning false as UuidFromString is always returning RPC_S_INVALID_STRING_UUID telling that the string UUID/GUID 'GuidString' is invalid.
Priya Sundar
|
|
|
|
|
Priya_Sundar wrote: Now this function is always returning false as UuidFromString is always returning RPC_S_INVALID_STRING_UUID telling that the string UUID/GUID 'GuidString' is invalid.
Wow.
This is the first time you give a proper error report.
You never mentioned this function before.
OK. For me
#include "stdafx.h"
#include <atlstr.h>
#include <iostream>
#include <RPC.h>
#pragma comment( lib, "Rpcrt4")
int _tmain(int argc, _TCHAR* argv[])
{
const char szValue[] = "{A89377EA-D4ED-4A03-A37F-4A9DE785E1A9}";
CString szGuidString( szValue+1, strlen(szValue)-2);
GUID ret = { 0 };
const RPC_STATUS status = UuidFromString( (unsigned char*)(LPCTSTR)szGuidString, &ret);
if( status == RPC_S_OK)
{
...
}
else
{
...
}
return system("pause");
} worked.
Note the double cast in the UuidFromString-call: It is used to get the raw const TCHAR* from the CString , and the other cast tells the compiler "Shut up and take this as if it were unsigned s!".
That is not Unicode-compatible. Under Unicode, the CString would hold wchar_t s, and by forcing the compiler to tread them as a string of unsigned char s, anything could happen.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
sorry rest is 'result'
and i started trying with (unsigned char *) and ended up with the error
"error C2440: 'type cast' : cannot convert from 'class CString' to 'unsigned char *'"
so i started using various things like BSTR. And that is where i need help!
Priya Sundar
|
|
|
|
|
cast to (LPCTSTR) instead
|
|
|
|
|
The normal plain old C-String most function want is char* or const char* . That is a signed type.
Microsoft uses a specific macro named TCHAR , which boils down to char* in non-unicode and to (2 Byte-)wchar_t in Unicode builds. Very handy.
Likewise, TSTR denotes a null-terminated string consisting of TCHAR.
A pointer to a constant string consisting of TCHAR is called a LPCTSTR (long pointer to constant TSTR ).
The CString-class wraps the TCHAR s from you, and has a conversion operator to be used in place of a constant TSTR .
So, when you stop using unsigned char and start using TCHAR , you problems will go away automagically.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Priya_Sundar wrote: However, here i am not able to store it back to 'String'.
Why does that surprise you? No memory has been allocated for String . As it stands now, it points to wherever. try:
String = new unsigned char[result.GetLength() + 1];
strcpy(String, result);
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
sorry for the delayed post.
i was actually in a meeting.
to your problem,
Priya_Sundar wrote: However, here i am not able to store it back to 'String'. i am getting various compiler errors like
the quickest solution is ,
for(int i=0;i less than n;i++)
{
String[i]=cString.Getat(i);//or cString[i] must also should work.
}
gud luck.
-- modified at 10:08 Thursday 11th October, 2007
Suggestion to the members:
prefix your main thread subject with [SOLVED] if it is solved.
chandu.
|
|
|
|
|
i think the topic got far diverted here.
|
|
|
|