char

Is there an easy way to change a char in a string in C#?

Hi, I want to do this: string s = "abc"; s[1] = 'x'; and s will become "axc". However, it seems that string[i] only has a getter and has no setter. The compiler gives me the following error: "Property or indexer 'string.this[int]' cannot be assigned to -- it is read only" I guess I could make a loop and change the char i wa...

Java | compare char word in a char array

How do I get the index of a single word (represents in a char array) which can be found in a paragraph (again represents in a char array). the char represents the word char word[] = new char[]{'w','o','r','d'}; and here's the paragraph char para[] = new char[]{'f','g','q','z','y','i','o','p','w','o','r','d'}; I would like to get t...

linux kernel module char device

Hi Kernel Gurus, i'm writing a char device in linux - xubuntu , and i'm wondering if i have to implement ioctl OR maybe i can use the regular read write funcs?? thanks all, Amit ...

how to store 8 bits in char using C

what i mean is that if i want to store for example 11110011 i want to store it in exactly 1 byte in memory not in array of chars. example: if i write 10001111 as an input while scanf is used it only get the first 1 and store it in the variable while what i want is to get the whole value into the variable of type char just to consume onl...

Initialization strings in C

Hi all. I have a question about how is the correct way of manipulate the initialization of c strings For example the next code, isn't always correct. char *something; something = "zzzzzzzzzzzzzzzzzz"; i test a little incrementing the number of zetas and effectively the program crash in like about two lines, so what is the real size li...

C: save received Winsock packet to file as hex

I need to do what most packet monitoring programs do (Wireshark, tcpdump, etc.). When data is received through Winsock, I just need to convert the packet to a hex representation and save it to file. The data is just a simple char array. I've tried lots of things like sprintf but with no luck. I also don't want to use itoa since it's no...

Who determines the ordering of characters

I have a query based on the below program - char ch; ch = 'z'; while(ch >= 'a') { printf("char is %c and the value is %d\n", ch, ch); ch = ch-1; } Why is the printing of whole set of lowercase letters not guaranteed in the above program. If C doesn't make many guarantees about the ordering of characters in internal form, then...

Get key char (value) from keycode with shift modifier

I have been lucky to find String.fromCharCode(). It has helped me significantly. However, I noticed it doesn't take into account the shift modifier. I know the event.shiftKey property and use it, but right now I need to get the key value (eg: "A" or "a") which takes into account the shift key modifier. At first I used String.toLowerC...

Remove first char of string C

Im trying to remove the first char of the string and keep the remainder, my current code doesnt compile and im confused on how to fix it. My code: char * newStr (char * charBuffer) { int len = strlen(charBuffer); int i = 1; char v; if(charBuffer[0] == 'A' || charBuffer[0] == 'Q'){ for(i=1;i<len;i++) ...

Can you work with char's in VBScript?

I have a .NET Class that contains a property that returns a char value. I am accessing this assembly using a VBScript via COM. When i attempt to read the property that is of type (char) I get an error in my VBScript that reads Variable uses an Automation type not supported in VBScript. How can I get around this error. Is there a way to d...

Passing char array in a function?

Here is my problematic coding: I have to take in 2 player's name. Then when for the next part when the player marker changes the name stored in "currentPlayer" should change too the name stored in either playerOne or playerTwo. It doesn't so how do I fix that? Please solve, I tried to make it a reference variable with the & symbol but I...

Bizzare System.out.println() in Java Program

String messageFile = ... // Assume messageFile SHOULD have the string "MESSAGE" System.out.println("The messageFile is: " + messageFile + "!!"); Normally, one would expect the above command to output: The messageFile is: MESSAGE!!!! However, I am receiving this instead: !!e messageFile is: MESSAGE See how the above statement, the...

Does anyone have considerable proof that CHAR is faster than VARCHAR ?

Any benchmark, graph anything at all ? Its all academic and theoretical across the web. Ok its not the first time that this question has been asked, they all say that using CHAR results in faster selects? I even read in MySQL books, its all the same but I have not come across any benchmark that proves this. Can any one shed some light...

What is the proper way of implementing a good "itoa()" function ?

First, hi, I'm new to stackoverflow ! Well, I was wondering if my implementation of an "itoa" function is correct. Maybe you can help me getting it a bit more "correct", I'm pretty sure I'm missing something. (Maybe there is already a library doing the conversion the way I want it to do, but... couldn't find any) #include <stdio.h> #in...

C style char arrays - How many bytes do we store?

char firstName[32]; I understand that each char occupies 1 byte in memory. So does the above occupy 32 bytes of memory? Am I missing a pointer that takes up memory too or is this just 32 bytes? ...

UIDatePicker is not working with MonoTouch. Gives error "Unknown char: ."

I have been trying to use the UIDatePicker, both trying to make my own projects and also trying to use tutorials from Wrox. The problem is as soon as i have a UIDatePicker in my project, the xib file generates the error "Unknown char: .". It doesn't matter which SDK version or minimum OS version I choose in the solutions build options. ...

Deleting char array returned by getenv()

Should I free the memory allocated for the char array, pointer to which is returned by the char * getenv( char * ) function? And which way - C free() or C+ delete []? If no - why? I mean: char * ptr = getenv( "LS_COLORS" ); cout << ptr << endl; delete [] ptr; //Is this or free() call needed? Thank you. ...

How do you express (Keys.Control | Keys.M) in F#?

In C#, you can express characters for the KeyPress event in the form Keys.Control | Keys.M. In F#, Keys.Control ||| Keys.M doesn't work. What does? Edit: Interesting indeed. Using System.Windows.Forms.Keys.Control ||| System.Windows.Forms.Keys.M as per Johannes Rössel's suggestion below in the F# interactive window works exactly as he s...

C++ Pointer Arithmetic and Concatenation Question

How does this code concatenate the data from the string buffer? What is the * 10 doing? I know that by subtracting '0' you are subtracting the ASCII so turn into an integer. char *buf; // assume that buf is assigned a value such as 01234567891234567 long key_num = 0; someFunction(&key_num); ... void someFunction(long *key_num) { f...

How to get the binary presentation in hex value of a char

Given a char, how to convert this char to a two digit char, which is the hex value of the binary presentation? For example, given a char, it has a binary presentation, which is one byte, for example, 01010100, which is 0x54.....I need the char array of 54. ...