char Questions

3

Solved

Just out of curiousity (not really expecting a measurable result) which of the following codes are better in case of performance? private void ReplaceChar(ref string replaceMe) { if (replaceMe.Co...
Farl asked 20/4, 2016 at 8:22

7

Solved

I have a for loop in Java. for (Legform ld : data) { System.out.println(ld.getSymbol()); } The output of the above for loop is Pad CaD CaD CaD Now my question is it possible t...
Pharisee asked 3/11, 2011 at 19:36

3

Solved

Given a fixed-length char array such as: let s: [char; 5] = ['h', 'e', 'l', 'l', 'o']; How do I obtain a &str?
Confirmation asked 13/7, 2016 at 18:28

5

Solved

I feel like this is a really silly question, but I can't seem to find an answer anywhere! Is it possible to get a group of chars from a char array? to throw down some pseudo-code: char arry[20] =...
Crummy asked 23/1, 2011 at 23:12

45

Solved

A palindrome is a word, phrase, number or other sequence of units that can be read the same way in either direction. To check whether a word is a palindrome I get the char array of the word and co...
Jochbed asked 9/11, 2010 at 21:28

23

I have read this question to get first char of the string. Is there a way to get the first n number of characters from a string in C#?
Kirkman asked 11/4, 2013 at 6:22

4

I have an application where I accept a socket connection from a telnet client and put up a simple, keyboard driven character GUI. The telnet client, at least on Linux, defaults into line-at-a-time...
Thermogenesis asked 7/11, 2008 at 19:14

19

Solved

I want to convert a std::string into a char* or char[] data type. std::string str = "string"; char* chr = str; Results in: “error: cannot convert ‘std::string’ to ‘char’ ...”. What methods are ...
Rundlet asked 8/9, 2011 at 17:25

7

Solved

I want to compare two strings. Is it possible with strcmp? (I tried and it does not seem to work). Is string::compare a solution? Other than this, is there a way to compare a string to a char? ...
Sinclair asked 30/3, 2011 at 21:13

10

Solved

In Java, what would the fastest way to iterate over all the chars in a String, this: String str = "a really, really long string"; for (int i = 0, n = str.length(); i < n; i++) { char c = str.c...
Emelia asked 17/1, 2012 at 12:2

3

Solved

I am trying to find a function for select e.g. first 100 chars of the string. In PHP, there exists the substr function Does Ruby have some similar function?
Sandhurst asked 21/6, 2011 at 10:41

8

Solved

I'm wondering what the correct way to compare two characters ignoring case that will work for all cultures. Also, is Comparer<char>.Default the best way to test two characters without ignorin...
Kvass asked 8/9, 2009 at 16:13

5

Solved

I am trying to update a text field in a table of my postgresql database. UPDATE public.table SET long_text = 'First Line' + CHAR(10) + 'Second line.' WHERE id = 19; My intended result is that th...
Waddle asked 29/10, 2014 at 19:7

5

Solved

I'm doing an assignment where we have to read a series of strings from a file into an array. I have to call a cipher algorithm on the array (cipher transposes 2D arrays). So, at first I put all the...
Brocatel asked 9/3, 2012 at 2:1

9

Solved

Using GDB, I find I get a segmentation fault when I attempt this operation: strcat(string,&currentChar); Given that string is initialized as char * string = ""; and currentChar is char c...
Goatsbeard asked 29/1, 2011 at 2:48

14

I have a char and I need a String. How do I convert from one to the other?
Jute asked 17/11, 2011 at 18:37

5

Solved

Consider the following code: #include <iostream> #include <type_traits> int main() { std::cout << "std::is_same<int, int>::value = " << std::is_same<i...
Scarify asked 12/5, 2013 at 1:38

13

Solved

I have a java string, which has a variable length. I need to put the piece "<br>" into the string, say each 10 characters. For example this is my string: `this is my string which I need ...
Scatter asked 11/2, 2009 at 14:57

2

Solved

Does C++23 now provide support for Unicode characters in its basic char type, and to what degree? So on cppreference for character literals, a character literal: 'c-char' is defined as either: ...
Crescendo asked 6/9, 2023 at 20:46

11

Solved

While practicing Java I randomly came up with this: class test { public static void main(String arg[]) { char x='A'; x=x+1; System.out.println(x); } } I thought it will throw an error beca...
Hideout asked 15/6, 2013 at 15:6

7

Solved

char out_file_name[30]; ogSize = strlen(FileName); //i.e. - FileName_anylength.log (always.log) ogSize -= strlen(IN_FILE_SUFFIX); //amount of chars before .log strncpy( out_file_name, FileName,...
Proprioceptor asked 31/8, 2010 at 23:19

10

Solved

I just want to know if there's a better solution to parse a number from a character in a string (assuming that we know that the character at index n is a number). String element = "el5"; String s;...
Dagoba asked 11/2, 2011 at 11:11

9

Solved

Could smb please explaing the process of sorting characters of String alphabetically? For example, if I have String "hello" the output should be "ehllo" but my code is doing it wrong. public stati...
Tholos asked 12/5, 2015 at 18:57

5

Solved

Starting from char tval[20] = "temp:26.62"; how can I add a space character until tval is filled? I need that in the end to obtain this: char tval[20] = "temp:26.62 ";
Wolsey asked 13/11, 2015 at 9:14

5

I find myself often using variables that contain a very small range of numbers (typically from 1 to 10) and would like to minimize the amount of memory I use by using the char data type instead of ...
Venlo asked 22/4, 2013 at 6:53

© 2022 - 2025 — McMap. All rights reserved.