char

clearing a char array c

Hello, I thought by setting the first element to a null would clear the entire contents of a char array. char my_custom_data[40] = "Hello!"; my_custom_data[0] = '\0'; However, this only sets the first element to null. or my_custom_data[0] = 0; rather than use memset, I thought the 2 examples above should clear all the data. Many...

Can a string literal and a character literal be concatenated?

Why does name misbehave in the following C++ code? string name = "ab"+'c'; How would the equivalent code behave in Java/C#? ...

Delphi - Problem With Set String and PAnsiChar and Other Strings not Displaying

Hi. I was getting advice from Rob Kennedy and one of his suggestions that greatly increased the speed of an app I was working on was to use SetString and then load it into the VCL component that displayed it. I'm using Delphi 2009 so now that PChar is Unicode, SetString(OutputString, PChar(Output), OutputLength.Value); edtString.Text :...

Should a buffer of bytes be signed or unsigned char buffer?

Should a buffer of bytes be signed char or unsigned char or simply a char buffer? Any differences between C and C++? Thanks. ...

Howto read chunk of memory as char in c++

Hello I have a chunk of memory (allocated with malloc()) that contains bits (bit literal), I'd like to read it as an array of char, or, better, I'd like to printout the ASCII value of 8 consecutively bits of the memory. I have allocated he memory as char *, but I've not been able to take characters out in a better way than evaluating ea...

char * function not displaying correctly in C

#include <time.h> #include <stdio.h> #include <stdlib.h> char *czas() { time_t rawtime; struct tm * timeinfo; char buffer [80]; time ( &rawtime ); timeinfo = localtime ( &rawtime ); strftime (buffer,80,"Now it's %I:%M%p.",timeinfo); return buffer; } int main() { printf("%s",czas()); system("PAUSE"); } I dont know why, b...

How can I easily work with a char**?

I have a char** that I frequently need to insert into or perform a lookup. It is very tedious to realloc(), malloc() the array and insert strings. Is there any standard way that I can add strings to or do lookups in a char**? I guess I'm looking for something like string, but using char**'s instead. ...

How would you get an array of Unicode code points a .NET String?

BACKSTORY: I have a list of character range restrictions that I need to check a string against, but the char type in .NET is UTF-16 and therefore some characters become wacky (surrogate) pairs instead. Thus when enumerating all the char's in a string, I don't get the 32-bit Unicode code points and some comparisons with high values fail....

Representing char as a byte in Java

Hi all, I must convert a char into a byte or a byte array. In other languages I know that a char is just a single byte. However, looking at the Java Character class, its min value is \u0000 and its max value is \uFFFF. This makes it seem like a char is 2 bytes long. Will I be able to store it as a byte or do I need to store it as ...

How can I convert a character to a integer in Python, and viceversa?

I want to get, given a character, its ascii value. For example, for the character 'a', I want to get 97, and viceversa. Thanks, Manuel ...

Why does the compiler require convoluted syntax for this?

Or, "am I doing it wrong"? I am writing a small function that will return a string, quoted (as quoted-printable) if necessary, otherwise it returns it as is. A character is input into the function; the result is a string. What I tried to do at first was: private string QuotedChar(char ch) { if(ch < (char)128 && !char.IsWhiteSpace...

convert string to char c

Hello, I am working on a project where I can to convert a api digit to a char. I have used an array of string pointers to get the conversion. However, I want to return just a single ch, as my api that I am using will only accept a char. So ap_five will return "5". But I want to five to be a single char '5'. I thought maybe I could cast...

Non ASCII char in PHP?

Hello, I am trying to send something to serial port (r232) with PHP. I am using this class: http://www.phpclasses.org/browse/package/3679.html The problem is that I am allowed to send only 1 byte. But if I send something like "1", I am actually sending 49 (ASCII for 1). Instead of send("1"), I tried with send(1) but it is no good, becau...

Is the CHAR datatype in SQL obsolete? When do you use it?

The title pretty much frames the question. I have not used CHAR in years. Right now, I am reverse-engineering a database that has CHAR all over it, for primary keys, codes, etc. How about a CHAR(30) column? Edit: So the general opinion seems to be that CHAR if perfectly fine for certain things. I, however, think that you can design a da...

How to refactor, fix and optimize this character replacement function in java

While tuning the application, I found this routine that strips XML string of CDATA tags and replaces certain characters with character references so these could be displayed in a HTML page. The routine is less than perfect; it will leave trailing space and will break with StringOutOfBounds exception if there is something wrong with the...

Oracle Character Types

Is using a VARCHAR2 (1 BYTE) any less efficient than using CHAR(1 BYTE)? Is using a VARCHAR2 (2000 BYTE) any less efficient than using CHAR(1 BYTE), if I never put any value longer than one character in the field? ** By efficient, I meant efficient in both time (searching) and space (storing). ...

Char to int conversion in C.

If I want to convert a single numeric char to it's numeric value, for example, if: char c = '5'; and I want c to hold 5 instead of '5', is it 100% portable doing it like this? c = c - '0'; I heard that all character sets store the numbers in consecutive order so I assume so, but I'd like to know if there is an organized library fun...

Convert CString to character array?

How to convert CString in MFC to char[] (character array) ...

Visual Studio 2008 with Vista, GLUT projects gives error on runtime

I'm sure that there is nothing wrong with my project. Because I have tried it on my ex computer with visual studio 2005 and windows xp pro, and it works error-free. I can compile my project. There is no errors on build phase.But when I try to run my project it says "*.exe has stopped working". Then I runned it on debugger mode. I saw t...

Marshalling C dll code into C#

I have the following C-code signature in a dll: extern __declspec(dllexport) unsigned char * funct_name (int *w, int *h, char **enc, int len, unsigned char *text, int *lp, int *mp, int *ep) The C function can modify w, h, enc, lp, mp, and ep (though the latter three can be null and it won't do anything. I'm using the following in C# ...