toupper

Reimplementing ToUpper()

时光总嘲笑我的痴心妄想 提交于 2019-12-10 18:25:15
问题 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 回答1: I download the Unicode tables I import the tables into a database I write a method upper(). Here is a sample implementation ;) public static String upper(String s) { if (s == null) { return null; } final int N = s.length(); // Mind the optimization! PreparedStatement stmtName = null; PreparedStatement stmtSmall = null;

Converting to uppercase in C++

这一生的挚爱 提交于 2019-12-08 04:20:14
问题 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 I make char * something = "m"; contain "M" ? 回答1: I find you choice of C strings disturbing.. but anyway. You can't change a string literal ( char *something ). Try an array: char something[] = "m"; something[0] = toupper(something[0]); To change

How to set a string to all lowercase [duplicate]

落花浮王杯 提交于 2019-12-07 05:19:23
问题 This question already has answers here : How do I lowercase a string in C? (5 answers) Closed 6 years ago . I have a char foo[SIZE]; //(string) and have inputed it correctly using %s (as in it printfs the correct input), but now want to set it to lowercase. So I tried using if (isupper(*foo)) *foo=tolower(*foo); ie when I do: printf("%s" foo); //I get the same text with upper case The text does not seem to change. Thank you. 回答1: foo isn't a pointer, so you don't want to use it as one. You

How to set a string to all lowercase [duplicate]

折月煮酒 提交于 2019-12-05 11:19:44
This question already has an answer here: How do I lowercase a string in C? 5 answers I have a char foo[SIZE]; //(string) and have inputed it correctly using %s (as in it printfs the correct input), but now want to set it to lowercase. So I tried using if (isupper(*foo)) *foo=tolower(*foo); ie when I do: printf("%s" foo); //I get the same text with upper case The text does not seem to change. Thank you. foo isn't a pointer, so you don't want to use it as one. You also don't have to check whether a character is an upper-case letter before using tolower -- it converts upper to lower case, and

How would you convert alpha characters to n string to uppercase in C? [closed]

三世轮回 提交于 2019-12-02 23:39:20
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last year . This is what I have so far. I'm just trying to understand how to implement this function. char toupper(char s[]) { s[50] = "hello"; int i = 0; int len; len = strlen(s); while(i < len) //converting to upper until the length is reached. { s[i] = putchar(toupper(s[i])); i++; } return s[i]; } 回答1: It

How would you convert alpha characters to n string to uppercase in C? [closed]

…衆ロ難τιáo~ 提交于 2019-12-02 13:39:53
This is what I have so far. I'm just trying to understand how to implement this function. char toupper(char s[]) { s[50] = "hello"; int i = 0; int len; len = strlen(s); while(i < len) //converting to upper until the length is reached. { s[i] = putchar(toupper(s[i])); i++; } return s[i]; } It seems that OP wants to convert a string to upper case. Now here somehow OP messed up the assignment part. The code can be boiled down to assigning uppercase characters to the string passed. But here, the code is doing something that compiler complains about. invalid conversion from 'const char*' to 'char'

Read input from a file, capitalize first letter, make every other letter lowercase, and output into a separate file

那年仲夏 提交于 2019-12-02 04:12:21
问题 I am supposed to ask the user for two file names (input and output files). The contents from the input file should be read and the first letter of each sentence should be made uppercase while every other letter should be made lowercase. The results should then be stored in the output file. I am aware that there are ways of using the toupper and tolower functions that include pointers, arrays, or even ASCII values of chars but I am trying to get this code to work by using if/else and while

Read input from a file, capitalize first letter, make every other letter lowercase, and output into a separate file

a 夏天 提交于 2019-12-02 01:13:31
I am supposed to ask the user for two file names (input and output files). The contents from the input file should be read and the first letter of each sentence should be made uppercase while every other letter should be made lowercase. The results should then be stored in the output file. I am aware that there are ways of using the toupper and tolower functions that include pointers, arrays, or even ASCII values of chars but I am trying to get this code to work by using if/else and while statements, as well as boolean statements. I have had various results ranging from all the letters being

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

∥☆過路亽.° 提交于 2019-12-01 11:04:33
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 (\x -> not('p' `elem` x || 'q' `elem` x)) myList It removes the unwanted elements from the list properly, however I can't apply toUpper on this list since the type of toUpper is Char. I tried it with map and it does not work. delAndUpper myList = map toUpper (filter (\x -> not('p' `elem` x || 'q' `elem` x)) myList) I know, that toUpper in this line

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

让人想犯罪 __ 提交于 2019-12-01 07:57:02
问题 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 (\x -> not('p' `elem` x || 'q' `elem` x)) myList It removes the unwanted elements from the list properly, however I can't apply toUpper on this list since the type of toUpper is Char. I tried it with map and it does not work. delAndUpper myList =