Click here to Skip to main content
15,887,135 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: c++ program Pin
Member 148568768-Jun-20 5:23
Member 148568768-Jun-20 5:23 
GeneralRe: c++ program Pin
Richard MacCutchan8-Jun-20 5:34
mveRichard MacCutchan8-Jun-20 5:34 
GeneralRe: c++ program Pin
Member 148568768-Jun-20 5:51
Member 148568768-Jun-20 5:51 
GeneralRe: c++ program Pin
Richard MacCutchan8-Jun-20 6:00
mveRichard MacCutchan8-Jun-20 6:00 
GeneralRe: c++ program Pin
Member 148568768-Jun-20 6:26
Member 148568768-Jun-20 6:26 
GeneralRe: c++ program Pin
Richard MacCutchan8-Jun-20 6:38
mveRichard MacCutchan8-Jun-20 6:38 
GeneralRe: c++ program Pin
Eddy Vluggen8-Jun-20 8:31
professionalEddy Vluggen8-Jun-20 8:31 
GeneralRe: c++ program Pin
Member 148568768-Jun-20 8:46
Member 148568768-Jun-20 8:46 
GeneralRe: c++ program Pin
Eddy Vluggen8-Jun-20 8:50
professionalEddy Vluggen8-Jun-20 8:50 
GeneralRe: c++ program Pin
Member 148568768-Jun-20 9:01
Member 148568768-Jun-20 9:01 
GeneralRe: c++ program Pin
Member 148568768-Jun-20 9:09
Member 148568768-Jun-20 9:09 
GeneralRe: c++ program Pin
Richard MacCutchan10-Jun-20 5:19
mveRichard MacCutchan10-Jun-20 5:19 
GeneralRe: c++ program Pin
Eddy Vluggen10-Jun-20 4:11
professionalEddy Vluggen10-Jun-20 4:11 
AnswerRe: c++ program Pin
Patrice T31-Jul-20 12:57
mvePatrice T31-Jul-20 12:57 
QuestionStrings in C | The program gives wrong output on string composed of both Upper case and lower case (Logic : ASCII Comparision) Why? Pin
Member 148492461-Jun-20 2:37
Member 148492461-Jun-20 2:37 
AnswerRe: Strings in C | The program gives wrong output on string composed of both Upper case and lower case (Logic : ASCII Comparision) Why? Pin
Richard MacCutchan1-Jun-20 3:15
mveRichard MacCutchan1-Jun-20 3:15 
GeneralRe: Strings in C | The program gives wrong output on string composed of both Upper case and lower case (Logic : ASCII Comparision) Why? Pin
k50541-Jun-20 4:22
mvek50541-Jun-20 4:22 
Richard MacCutchan wrote:
... expressions like if(65<=name[i]<=90); that is not valid C

Strictly speaking, that is valid C, though it does not do what you might expect. In fact it will always return 1 (true), since it is equivalent to if ( (65 <= name[i]) <= 90). The expression (65 <= name[i]) evaluates to either true (1) or false (0), both of which are <= 90, so the expression will always be true.

Better than using "magic numbers", or even char constants, why not useisupper(), islower(), toupper() and tolower())?
C++
#include <ctype.h>

if( islower(name[i] )
   name[i] = toupper(name[i]);
else if ( isupper(name[i]) )
   name[i] = tolower(name[i]);

That's clear and concise, I think, and has the advantage that if you need to migrate to an non ASCII environment [e.g. EBCDIC, but not UTF-X (and really, who does, these days?)], it will still work without any code changes. It will also work for locales other that C/POSIX

For the advanced reader I offer, also
C++
name[i] = isupper(name[i]) ? tolower(name[i]) : toupper(name[i])
toupper() and tolower() only transform characters that evaluate true for isupper() and islower(), respectively, so non alphabetic chars are not changed by passing through them. The ternary ?: operator should be approached with caution though, as it often makes code harder to understand, particularly for users new to C
Keep Calm and Carry On

GeneralRe: Strings in C | The program gives wrong output on string composed of both Upper case and lower case (Logic : ASCII Comparision) Why? Pin
Richard MacCutchan1-Jun-20 5:05
mveRichard MacCutchan1-Jun-20 5:05 
GeneralRe: Strings in C | The program gives wrong output on string composed of both Upper case and lower case (Logic : ASCII Comparision) Why? Pin
kalberts1-Jun-20 7:25
kalberts1-Jun-20 7:25 
GeneralRe: Strings in C | The program gives wrong output on string composed of both Upper case and lower case (Logic : ASCII Comparision) Why? Pin
Richard MacCutchan1-Jun-20 9:28
mveRichard MacCutchan1-Jun-20 9:28 
QuestionRun executable with arguments Pin
Erich Ruth3-May-20 3:04
Erich Ruth3-May-20 3:04 
AnswerRe: Run executable with arguments Pin
Richard MacCutchan3-May-20 3:14
mveRichard MacCutchan3-May-20 3:14 
AnswerRe: Run executable with arguments Pin
Victor Nijegorodov3-May-20 4:50
Victor Nijegorodov3-May-20 4:50 
QuestionVisual C++/CLI Pin
F_Square3-Apr-20 15:26
F_Square3-Apr-20 15:26 
AnswerRe: Visual C++/CLI Pin
Richard MacCutchan3-Apr-20 22:00
mveRichard MacCutchan3-Apr-20 22:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.