Questions tagged [toupper]

In C / C++ toupper function converts a given character to uppercase according to the character conversion rules defined by the currently installed C locale. In the default "C" locale, the following lowercase letters abcdefghijklmnopqrstuvwxyz are replaced with respective uppercase letters ABCDEFGHIJKLMNOPQRSTUVWXYZ.

176 questions
4
votes
4 answers

toupper returns integer rather than char

for the following function void display() { for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { if (board[i][j] < 84 && (i+j)%2 == 0) SetConsoleTextAttribute( GetStdHandle(…
jeremy south
  • 161
  • 1
  • 3
4
votes
4 answers

Change first word in a sentence to uppercase

I am looking to convert the first word of a sentence into uppercase but unsure how would I go about it. This is what I have so far: $o = ""; if((preg_match("/ibm/i", $m)) || (preg_match("/hpspecial/i", $m))) { $o = strtoupper($m); } else { …
ash
  • 93
  • 5
  • 14
3
votes
3 answers

Ambiguous result with char and toupper

How does 'ab' was converted to 24930 when stored in char? #include int main(){ char c = 'ab'; c = toupper(c); printf("%c", c); return 0; } GCC compiler warning : Overflow in conversion from 'int' to 'char' changes value…
Naman Jain
  • 195
  • 2
  • 15
3
votes
1 answer

Why doesn't my function to transform letters into uppercase work if I pass in strings as variables?

I wrote a function in C that transforms all lowercase letters into uppercase with pointers. It looks like the following: char *ft_strupcase(char *str) { char *str_begin; str_begin = str; while (*str != '\0') { if (*str…
Robb U
  • 31
  • 1
3
votes
2 answers

Homemade toupper: looks the same but not identical

For my optimizations, i would like to get a decent toupper in Rcpp. I'm very new to C++, and as for know I've done that: #include using namespace Rcpp; void C_toupper_String(const String& s) { for (char *p =(char…
Arnaud Feldmann
  • 761
  • 5
  • 17
3
votes
2 answers

Using to upper incorrectly? Working code until I entered toupper

My program worked like it was supposed to until I added the toupper part into my program. I've tried looking at my error code but it's not really helping. The errors are: no matching function to call 2 arguments expected, one provided So I know…
JOHNSMITH8338
  • 85
  • 2
  • 7
3
votes
2 answers

Converting a cstring to camelcase

So my task is to fill out my function to work with a test driver that feeds it a random string during every run. For this function I have to convert the first character of every word to a capital and everything else must be lower. It mostly works…
RyeMan
  • 35
  • 2
  • 6
3
votes
6 answers

Reimplementing ToUpper()

How would you write ToUpper() if it didn't exist? Bonus points for i18n and L10n Curiosity sparked by this: http://thedailywtf.com/Articles/The-Long-Way-toUpper.aspx
3
votes
2 answers

Force a stringBuilder to an upper case

I was wondering if there is anyway to use something like the toUpperCase for StringBuilder? Below is my code, I am trying to take user input of a phrase and turn it into an acronym. Someone helped me out by suggesting StringBuilder but I can't…
NoobCoderChick
  • 617
  • 3
  • 21
  • 40
3
votes
3 answers

How to convert a string (char *) to upper or lower case in C

I have a struct: typedef struct entry { char *surname; int house_no; char *postcode; } BEntry; and a function to convert strings to upper case: void toUpper(char *str){ while (*str != '\0') { *str = toupper(*str); str++; …
Highway62
  • 800
  • 1
  • 10
  • 25
3
votes
1 answer

Understanding Haskell's `toUpper`

Looking at the Haskell source for toUpper: toUpper c = chr (fromIntegral (towupper (fromIntegral (ord c)))) ... foreign import ccall unsafe "u_towupper" towupper :: CInt -> CInt What is the meaning of chr, as well as u_towupper? I'm curious…
Kevin Meredith
  • 41,036
  • 63
  • 209
  • 384
3
votes
2 answers

Return type error of linked list toUppercase method

I have a class called LString (a linked list class) that works with my other Node class. I have written a toUppercase() method that traverses the character sequence and converts lowercase to uppercase. My issue is the return type, a problem I seem…
AOE
  • 109
  • 2
  • 7
  • 14
3
votes
3 answers

Haskell - Capitalize all letters in a list [String] with toUpper

I have a list [String] the task ist to remove those elements in the list, which have "q" or "p" and then capitalize all letters in the list with toUpper. What I tried yet is as follow: delAndUpper :: [String] -> [String] delAndUpper myList = filter…
John
  • 429
  • 3
  • 8
  • 20
3
votes
6 answers

Y/N or y/n in loop

I have trouble implementing the Y/N or y/n in the loop. I've designed it in a way that a user can use both the capital and small letters of the Y and N for their answer in a loop. by the way here's my code but can't seem to make it work: do …
Dwayne Radar
  • 195
  • 1
  • 4
  • 10
2
votes
5 answers

Converting to uppercase in C++

Let's say you have: const char * something = "m"; How would one make this uppercase, using toupper (or something else, if applicable)? I want to use a char * instead of a string (I can use a string, but then I have to use str.c_str()). So, how can…
John
  • 107
  • 1
  • 4
  • 11
1
2
3
11 12