char

jquery plugin issues with counting chars when returns are used

I have a problem with jquery.charcounter.js its not counting returns as /r/n its counting them as 1 char instead of 3 or 4 here is the code is there a way around it if (el.val().length > max) { el.val(el.val().substring(0, max)); if (settings.pulse && !p) { pulse(container, true); ...

Which one to use const char[] or const std::string?

Which is better for string literals, standard string or character array? I mean to say for constant strings, say const char name[] = "so"; //or to use const string name = "so"; ...

building up char * for network stream communication

Hello, I need to create a char * which has the following layout: length of username in network byte order (htonl) username length of password in network byte order (htonl) password 7 null characters (\0) length of the char * in network byte order (htonl) Can someone provide some advise as to how to build up this char * concatenating t...

Looping a Const Char

I need to loop a const char, and I've used a simple example of string loop: const char *str; for(int i = 0; i < 10; ++i) { str += " "; } But when I tried to compile, I got this: ubuntu@eeepc:~/Test_C_OS$ gcc -o kernel.o -c kernel.c -Wall -Wextra -nostdlib -nostartfiles -nodefaultlibs kernel.c:26: error: ‘for’ loop initial dec...

Convert Linux C Char Array to Int

Hi Guys, need some advice on this one as im struggling abit and cannot figure it out. i have a file that gets updated on a PC to indicate a system ran and what time it ran. i am writing a very simple linux console app (will eventually be a nagios plugin). that reads this file and responds depending on what it found within the file. i a...

Pointer, String Problem in C

I'm using C for a class project for the first time after first learning C++, so syntax is killing me... Basically, I need to store a string given by a function into a separate variable for later use. I have an array of chars declared like this char foo[]; A function that I'm given assigns a bunch of characters into this array (or po...

Character.getNumericValue() issue

I'm probably missing out something, but why the two numeric values are equal to -1? System.out.println(Character.getNumericValue(Character.MAX_VALUE)); System.out.println(Character.getNumericValue(Character.MIN_VALUE)); returns: -1 -1 ...

Convert char[] to System::Object

In C++ I have a char[256] variable that is populated by a call to an external DLL which fills it with data. From there I would like to add the char[] as a ComboBox item. char name[256]; name[0] = "76"; comboBox1->Items->Add(name); This creates a build error because char[] is not a type of System::Object. Any ideas on converting the ch...

Python: How can I increment a char?

I'm new to Python, coming from Java and C. How can I increment a char? In Java or C, chars and ints are practically interchangeable, and in certain loops, it's very useful to me to be able to do increment chars, and index arrays by chars. How can I do this in Python? It's bad enough not having a traditional for(;;) looper - is there an...

How can I display variable strings using C++ and PDCurses?

I'm extremely sorry to post such an embarrassingly newbish question, but I haven't mucked around much with C++ since my college days and I think at some point I drank all that I knew about pointers and C++ strings right out of my head. Basically, I'm creating a C++ console app (a roguelike, to be precise) with PDCurses to handle output....

Empty character in Objective-C

I'm creating some code that will find a space between characters, and use the characters before the space and the ones after it. These characters are stored in a NSString. Here is what I have so far, however, it's not seeing the empty character. NSString *tempTitle = self.title; unsigned int indexOfSpace; // Holds the index of the c...

Need to convert String^ to char *

I am using the .NET DateTime to get the current date and time. I am converting it to a string to use as part of a file name. The problem is the OpenCV command to save an image requires a char * not a string type, and DateTime will only output a String^ type. How do I make this work? Heres the code not completed String^ nowString = DateT...

Convert CharCode to Char?

What I need ok I googled this and there are many tutorials on how to get the charCode from the character but I cant seem to find out how to get the character from the charcode. Basically I am I am listening for the KeyDown event on a TextInput. I prevent the char from being typed via event.preventDefault(); Later I need to add the te...

Can all keys be represented as a single char in c++?

I've searched around and I can't seem to find a way to represent arrow keys or the escape key as single char in c++. Is this even possible? I would expect that it would be similar to \t or \n for tab and new line respectively. Whenever I search for escaped characters, there's only ever a list of five or six well known characters. ...

Regular expression for accepting alphnumeric characters (6-10 chars) .NET, C#

I am building a user registration form using C# with .NET. I have a requirement to validate user entered password fields. Validation requirement is as below. It should be alphanumeric (a-z , A-Z , 0-9) It should accept 6-10 characters (minimum 6 characters, maximum 10 characters) With at least 1 alphabet and number (example: stack1ove...

Storing/Comparing u_char passed to function

I have a simple function that passes a variable "var" as a u_char array. I have no difficulty printing that array. printf("%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x", var[0], var [1], var[2], var[3], var[4], var[5]); Prints the mac address out just the way I like it. I cannot for the life of me figure out the proper way to store this...

Are there machines, where sizeof(char) != 1 ?

Are there machines (or compilers), where sizeof(char) != 1 ? Does C99 standard says that sizeof(char) on standard compliance implementation MUST be exactly 1? If it does, please, give me section number and citation. Upd: If I have a machine (CPU), which can't address bytes (minimal read is 4 bytes, aligned), but only 4-s of bytes (uint...

C / C++ How to copy a multidimensional char array without nested loops?

I'm looking for a smart way to copy a multidimensional char array to a new destination. I want to duplicate the char array because I want to edit the content without changing the source array. I could build nested loops to copy every char by hand but I hope there is a better way. Update: I don't have the size of the 2. level dimension...

Char * (pointer) function

I need to pass in a char * in a function and have it set to a cstring value. I can properly set it as a string in the function, but it doesn't seem to print out correctly in the function that called the char * function in the first place. int l2_read(char *chunk,int length) { chunk = malloc( sizeof(char) * length); int i; f...

C++ Confusion. Reading Integer From Text File. Convert to ASCII

I am learning C++ for the first time. I have no previous programming background. In the book I have I saw this example. #include <iostream> using::cout; using::endl; int main() { int x = 5; char y = char(x); cout << x << endl; cout << y << endl; return 0; } The example makes sense: print an integer and the AS...