char

Pointers's pointer c++ char intialization

I'm with a doubt In initialization of this in C++: char** A_Function() { char** charList = new char*[2]; charList[0] = "abcde"; charList[1] = "fghij"; return charList; } There's no problem "on compiling this code", but I'm not sure about the behaviour. 1 - the char list: char* is on heap ok? 2 - the charList[n_positio...

Where in the ruby doc is string.chars defined?

I've been learning ruby by solving project euler problems and in one solution to a problem I saw you could do something like "12341".chars.inject(1) { |prod, n| prod * n.to_i }. I've looked on the ruby doc but I can't find where String#chars is defined. Can anyone explain how that works? ...

Properly Reading a Char from an Int in C on a Stack

Hi all, so I'm having a crazy time right now reading characters off a stack. I'm storing the char as an int, so I can check for the EOF signal, but things aren't going so well. I'm new to the implementation of stacks, so things are probably just wrong somewhere. Here's my code. I'm getting both the incorrect top character on the stack (...

Is there something to double output a % character?

Is there something in a BATCH file that would double a % character? The test.txt INPUT file contains the following " Hello World The filename is : filename with spaces and 50% percentages signs.txt The %~nf removes extenstions Is there something to double a % charactor? As I would like 50% to be outputed as 50%% because the output o...

Need to convert char* (pointer) to wchar_t* (pointer)

I am doing some serial port communcation to a computer controlled pump and the createfile function I used to communicate requires the com port name to be parsed as a wchar_t pointer. I am also using QT to create a form and aquire the com port name as a QString. This QString is converted to a char array and pointed to as follows: c...

boost::interprocess::string conversion to char*

Is it possible to convert a boost::interprocess::string to an std::string or to a const char*? Something like c_str()... E.g.: boost::interprocess::string is = "Hello world"; const char* ps = is.c_str(); // something similar printf("%s", ps); I could even get a copy of the string in a non-shared memory block. E.g.: boost::interp...

C++ Unicode Bullet Point

Hi stackoverflow! I am trying to insert the Unicode character U+2022 (bullet •) in my C++ application. I can't figure out how to convert that U+2022 to a char/string for use in std::string constructor... char bullet = char(0x2022); mPassword.SetText( std::string(mText.length(), bullet) ); This one doesn't work. Hope you can help !!...

Can't get methods in a Class to work.

static private function removeAccentedLetters($input){ for ($i = 0; $i < strlen($input); $i++) { $input[$i]=self::simplify($input[$i]); } return $input; } static private function simplify($in){ switch ($in) { case 'Á': return 'A'; case 'á': return 'a'; default: return $in; ...

Correcting characters in a string?

Hello all. I need to correct unwanted chars in a string. unwanted characters: "c" instead of "ç" "i" instead of "ı" "u" instead of "ü" "g" instead of "ğ" "o" instead of "ö" "s" instead of "ş" I have written this method. But it doesnt work. public string UrlCorrection(string text) { text = (text.ToLower()).Trim(); ...

How to return a char array created in function?

Hello, I've been programming badly for quite a while and I only really just realised. I have previously created many functions that return character strings as char arrays (or at least pointers to them). The other day someone pointed out that when my functions return the char arrays pointed to by my functions have gone out of scope and...

Rotating an array of bits in C

I've just started learning C and I'm having some problems with some code I want to write. Basically I have this struct that is a bit array, with the number of bits in the array, and a pointer to a buffer of chars, that stores the bits. My strategy for rotating the bit array is simply taking the number of rotations (mod the length to a...

What type to use to store a single char in Scala?

I am writing a function which is meant to take a character as an argument and return a character. Using String for this looks a bit strange for me. Should I, or there is something like a char type in Scala 2.8? ...

Error passing C array as char* function parameter

I'm trying to make a simple code in c language (Stupid question, but I'm learning), I dont understand that this code gives me an error ... I must be doing wrong, I can not know that I have to change...sorry for my English ... thanks in advance to all #include <stdio.h> #include <ctype.h> char* to_up(char* str_); int main() { cha...

Enforcing valid input in Java

I have a class I wrote in Java and one of the methods is getCommand() The purpose of this method is to read in a string and see what the user typed in matches any of the acceptable commands. This is how I wrote it initially: public char getCommand(){ System.out.println("Input command: "); command = input.nextLine(); whi...

Standard SQL - CHAR to ASCII

Using standard SQL, SQL-92, how can I convert a character to an ASCII value? In MySQL it's easy using the ascii() function, but SQL-92 doesn't have this. ...

Trouble with characters in C

Hi Why does this not compile? Cant see the error #include <stdio.h> #include <string.h> #include <stdlib.h> int main(void) { char *c; FILE *f = fopen("file.txt", "r"); if(f == NULL) { printf("Could not open file"); } while((c = fgetc(f)) != EOF) { if(strcmp(c, " ") == 0) { printf(" ");...

Converter and compresser between ASCII and Binary

Hi I am trying to make a very easy converter/compressor; the program should take a file with 4 different types of ASCII characters and writ it out as binary to a file. The program should also read the binary file and convert it to ASCII and print it out on the screen. Under is my code, I can’t really get the char/cstring. What types of ...

Java char contains value > 255 ?

Hi, I get a char array from a socket : char[] cbuf = new char[3]; inputStream.read(cbuf, 0, 3); // read 3 chars in buffer "cbuf", offset = 0 Then when I print that : System.out.println("r:"+(int)cbuf[0]+" g:"+(int)cbuf[1]+" b:"+(int)cbuf[2]); I get at some point : ... r:82 g:232 b:250 r:82 g:232 b:250 r:66 g:233 b:8224 The 8224...

Unexpected pointer randomly changes. Why would it change for? Breaks pointer arithmetic.

Hello. Maybe I'm being stupid but I can't figure out why a pointer is being changed in this function. I have included "printf" and "puts" to show the problem. The left braket pointer is changing and invalidates the pointer arithmetic I want to do for string manipulation. Another question I have - Is it dangerous to expect char pointers ...

Overlayed text?

Hi! Quick text-processing question. It's not necessarily related to programming, but this is the best place I figured I should go. Rate down to tell me this kind of question is not welcome here. (Though, I really like my one little reputation point.) Anyways, how can I encode text so that two characters get rendered in the same charspa...