|
My function:
void ConvertToUpper ( char name[] )<br />
{<br />
cin >> name ;<br />
int i = 0;<br />
while(name[i] != '\0')<br />
{<br />
if(name[i] > 'Z')<br />
name[i] += 'A' - 'a';<br />
i++;<br />
}<br />
}<br />
Why when entered, will it take John_Doe, and convert it to JOHN?DOE
|
|
|
|
|
yeah, just think about it a second (or 2 or 3 ) more.
Do/run/simulate your "algo" on paper, and see what happens to the "_" caracter.
This signature was proudly tested on animals.
|
|
|
|
|
void ConvertToUpper(char name[])
{
cin >> name;
int i = 0;
while(name[i] != '\0')
{
if(name[i] >= 'a' && name[i] <= 'z')
name[i] += 'A' - 'a';
i++;
}
}
Manish Agarwal
manish.k.agarwal @ gmail DOT com
|
|
|
|
|
Manish, thanks for the response, I meant--when you input John_Doe, it should translate to JOHN DOE with a space.
Now I see that "_" ASCII value is 95; if I add A - a to "_", i'll get "?".
So where would I add -63 to get a " " instead of a "?" when converting a "_"?
|
|
|
|
|
Why on earth would you wish to make it as cryptic as adding -63 to the numerical representation of the _ character?
Consider the following addition to your unchecked code:
void ConvertToUpper ( char name[] )
{
cin >> name ;
int i = 0;
while(name[i] != '\0')
{
<code>if (name[i] == '_')
name[i] = ' ';
else </code>if(name[i] > 'Z')
name[i] += 'A' - 'a';
i++;
}
}
EDIT: made an error and assigned the = character to name[i] if it was previously _
|
|
|
|
|
I hope you are doing some C/C++ string exercises. Well, I've modified the program for you. It converts small to caps, ignore capital and numbers and converts all symbols to space. Please have a look at it.
void ConvertToUpper ( char name[] )
{
cin >> name ;
int i = 0;
while(name[i] != '\0')
{
if( name[i] >= 'a' &&
name[i] <= 'z' )
{
name[i] -= 32;
}
else if (( name[i] < 'A' ||
name[i] > 'Z'))
{
if( name[i] < '0' ||
name[i] > '9' )
{
name[i] = ' ';
}
}
i++;
}
}
I just thought about my old C/C++ string lessons.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
I can only presume you already know about the toupper function built into the C runtime library and want to write the case conversion by hand? Because that's what I'd be using. Or the C++ version, which is locale-aware?
|
|
|
|
|
jonig19 wrote: Why when entered, will it take John_Doe, and convert it to JOHN?DOE
Because that's what you've instructed it to do. Do the math. If the underscore's ASCII value is 95, then:
95 + (65 - 97) = 95 + (-32) = 63, which is the ASCII value of the question mark.
Perhaps you meant to do something like this which only affects lowercase letters:
while (name[i] != '\0')
{
if ((name[i] >= 'a') && (name[i] <= 'z'))
name[i] = name[i] - ('a' - 'A');
i++;
}
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
HI, i am currently developing application in windows ce using c++ language
and i need to be able to execute command line in my program
i ever use system(String) in vs2005 with no problem in xp however,
in windows ce, i always get error that system identifier is not found
do u guys know what keyword that has same functionality with system?
thanks
Arif Liminto
|
|
|
|
|
Hi all,
How does this translate to c++:
string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));
HashAlgorithm XHash = HashAlgorithm.Create("MD5");
byte[] keyArray = XHash.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
XHash.Clear();
TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
tdes.Key = keyArray;
tdes.Mode = CipherMode.ECB;
tdes.Padding = PaddingMode.PKCS7;
This is what I did but i am not sure if its correct because I didnt do the UTF8Encoding part.
TCHAR szKey[] = _T("Key");
DWORD pwlen = _tcslen(szKey);
result = CryptCreateHash(hProv,CALG_MD5,0,0,&hHash);
result = CryptHashData(hHash,(BYTE *)szKey,pwlen,0);
result = CryptDeriveKey(hProv,CALG_3DES,hHash,0,&hKey);
BYTE PadMode = CRYPT_MODE_ECB;
result = CryptSetKeyParam(hKey, PKCS5_PADDING, &PadMode, 0);
Please help me clarify things.
Thanks,
Jayjay
|
|
|
|
|
Does it produce the same hash for a sample string as the C# code? That's a good way to tell if it's the same.
|
|
|
|
|
Which is the best C++ ERP development toolkit ?
|
|
|
|
|
sumeet123 wrote: C++ ERP development toolkit
huu, what ?!
|
|
|
|
|
He is asking about a virus-development (namely E nable R emote P iracy) C++ toolkit.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Man, as anagrams are used for every little think with more than one word, if you don't explicitely explains what ERP means, you'll probably get a bunch of answers that are not related at all to your query...
|
|
|
|
|
If by ERP you're meaning 'Enterprise Resource Planning', then you're probably best off interfacing with your companies ERP system - that's likely to have an SDK available for interfacing to it. We use SAP for that...which is horrible.
|
|
|
|
|
I currently work on Siebel, which is a big CRM application... it is done in C++, but no C++ code is available to us. we just use the tools Siebel provide us.
|
|
|
|
|
The only one I have experience of is SAP. There's definitely interfacing mechanisms for that...but our IT department wouldn't let us use them to interface directly to SAP!
|
|
|
|
|
AFAIK, SAP have BAPI and IDOC for direct "push up" mechanisms...
but it also has EIM, right ?
|
|
|
|
|
I don't know it that well! In fact, I never looked at it again after I realised we weren't going to be able to be allowed to interface to it.
|
|
|
|
|
but there are good and bad ways to interface to an application... the supported ones and the others ^^ Some might have not understood this around you
|
|
|
|
|
|
Hello
I am a bit new to C++ and struggle to see the difference between MFC and windows form application.
Is there anyone that maby can give som example where to use either of them.
It looks for me that the windows form application is maby a bit easier, but is there than any limitations with that?
All answer are thanksful
Br
Frankis78
|
|
|
|
|
here is an easy difference :
MFC is native code
WinForms is .NET
|
|
|
|
|
thanks, but can you explain a bit more where you use those, in what setting?
Does it make any difference in the final result?
As i understand, they almost give the same result, but im unsure what i need to use?
Thanks
|
|
|
|