char

Count number of chars in char array including spaces until null char

I'm trying to count the number of chars in a char array including the space until the end of the string. The following compiles but doesn't return the correct value, I'm trying to use pointer arithmetic to interate through my array. int numberOfCharsInArray(char* array) { int numberOfChars = 0; while (array++ != '\0')...

Delphi: array of Char and TCharArray "Incompatible Types"

I've run across this "Incompatible types" error in the comment below a few times, and never been happy with why this isn't directly supported in Delphi 2007: program Project1; {$APPTYPE CONSOLE} type TCharArray = array of Char; procedure DoArray(Chars: array of Char); begin end; function ReturnTCharArray: TCharArray; var CharArray: T...

libxml2 questions about xmlChar*

I'm using libxml2. All function are working with xmlChar*. I found that xmlChar is an unsigned char. So I have some questions about how to work with it. 1) For example if I working with utf-16 or utf-32 file how libxml2 process it and returns xmlChar in function? Will I lose some characters then?? 2) If I want to do something with th...

C# string and char question

I just want to be sure: string X=""; char Char=X[0]; //an exception "Index was outside the bounds of the array" This means that the string is really treated as an array of chars, right? At least internally. ...

typedef problem

hey people kindly tell me if the following declaration is correct? if it is then kindly explain typedef char HELLO[5]; HELLO name; now what datatype is name? [as in a character,integer etc] i came to know that name will be an array of strings but when i run the following programme i get error #include<stdio.h> typedef char HEL...

How to convert this code to use string

char * recursivecombo(char *str, int choices, int level) { int len = strlen(str); level++; if( level == choices) { for (int i = 0; i < len -2; i++) { printf("%c", str[i]) ; } } else { for (int i = 0; i < len - 2; i++) { ...

How to make function return string in c++

Possible Duplicate: How to convert this code to use string I have a function like this: char *foo() { } How can I make it return a string instead? I tried string foo() { } but the compiler complains. ...

check for vowel in a given string

i would like to make a program which checks the character which is input is vovel or not but not able to input char with jTextField1 i tried Character.parseChar but nothing is happening. ...

Printing a string in C using a function

I'm brand new to C and am trying to learn how to take a string and print it using a function. I see examples everywhere using while(ch = getchar(), ch >= 0), but as soon as I put it into a function (instead of main()), it ceases to work. Right now, it's stuck in an endless loop... why is that? // from main(): // printString("hello"); v...

C++: Trouble Using String as Argument of a Function

Okay, I am having trouble with the following piece of code (in a header file): #ifndef XML_H_INCLUDED #define XML_H_INCLUDED #include "libxml/parser.h" #include "libxml/xmlwriter.h" #include <string> class XmlFile{ public: XmlFile(string filename){ file = xmlParseFile(filename); } xmlDocPtr file; //Pointer to xml...

a problem about using const char* to pass parameter

I first store the 3 value into a pair of map like this: void AddMenuAtlasTexture( int tag, const char* filename, const char* textureName ) { map<const char*, const char*> _item; _item.insert(pair<const char*, const char*>(filename, textureName)); m_texturesToLoad.insert(pair<int, map<const char*, const char*> >(tag, _item)); }; th...

How to convert an NSString to char

I am trying to convert an NSString to a ResType, as defined below in MacTypes.h. FourCharCode // A 32-bit value made by packing four 1 byte characters together typedef FourCharCode ResType; I think I could use [aString getCharacters:range:], but is there a more straight forward way to make this conversion? After trying suggestions fr...

c string basics, why unassigned?

Hi, I am trying to learn the basics, I would think that declaring a char[] and assigning a string to it would work. thanks int size = 100; char str[size]; str = "\x80\xbb\x00\xcd"; gives error "incompatible types in assignment". what's wrong? thanks ...

C++ converting an int to an array of chars?

Possible Duplicate: C++ convert int and string to char* Hello, i am making a game and I have a score board in it. The score is stored in an int variable but the library im using for the game needs an array of chars for its text outputting for my scoreboard. So how do i turn an int into an array of chars? int score = 1234; ...

Initializing a static const char* array

Hi, here is my question I have this in my .h file static const char *Title[]; How do I initialize the array in my .C file the array to lets say "first", "second", "third" ...

Is it possible to globally configure all char/varchar/text columns in a mysql database to use utf8?

I have a database that I had imported and accidentally created some tables as using latin1 by default. I've altered the tables and the database, but the columns are still latin1. I don't really have any reason to use latin1, so is there any way to just change all columns to use utf8? This is a development database, so it doesn't neces...

memory leak during char* manipulation

I do something like that in the loop : char* test = "\0"; test = strcat(test, somestr); ... char* tmp = strstr(test, 0, len); free(test); test = tmp; And get memory leak. What I do wrong? ...

Get the char on Control.KeyDown?

Hi When handling Control.OnKeyPress event, there is a KeyPressEventArgs that contains a KeyChar. For usability reasons I need exactly the same KeyChar but when handling OnKeyDown event. The KeyEventArgs does not contains any char related data. I mean, if press the A key with or without Shift its not affecting the KeyCode, KeyData or K...

Storing NULL characters (ASCII 0)

I've created a program in C++ that prompts the user for a filename and for the requested filesize. The program checks if the requested filesize is bigger than the actual filesize and then adds null characters (the ones with code 0) at the end of the file, until the requested filesize is reached. I have done it like this (with fstream): ...

Problem converting char to wchar_t (length wrong)

I am trying to create a simple datastructure that will make it easy to convert back and forth between ASCII strings and Unicode strings. My issue is that the length returned by the function mbstowcs is correct but the length returned by the function wcslen, on the newly created wchar_t string, is not. Am I missing something here? typed...