I'm looking through some code for learning purposes. I'm working through this portion of code.
// e.g. const unsigned char data={0x1,0x7C ... }
unsigned char buf[40];
memset(buf,0,40);
buf[0] = 0x52;
memcpy(buf+1, data, length); // What does buf+1 do in this situation?
On the last line where memcpy is called what does buf+1 do? buf is...
I'm wondering what the correct way to compare two characters ignoring case that will work for all cultures. Also, is Comparer<char>.Default the best way to test two characters without ignoring case? Does this work for surrogate-pairs?
EDIT: Added sample IComparer<char> implementation
If this helps anyone this is what I've decided to us...
I am using ADO.NET to fill a datatable from an Excel (xls) worksheet.
I got unexpected chars. At first I thought they came somehow during the import and so I tried to emininate them in the C# program but nothing I tried worked.
Finally I traced the chars back to Excel and I was able to use the replace function in Excel to replace the c...
Hi, I'm writing a small program in C that will read input from the console. Then put it into a char array. After that I need to split the array into words. I'm not sure how to do this. So far I have put the input into a char array. I need to know if there is a way to tokenize based on a blank character. Or any other suggestions on how ...
How do I put the value of 0x04 in register 4 if the instruction was 1rxy?
1RXY-Load register R with the value at memory address XY
#include <stdio.h>
unsigned char r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,ra,rb,rc,rd,re,rf;
void reg_check(unsigned char reg);
void rxy1(unsigned char reg, unsigned char val);
int main(){
unsigned char memloc1=...
I read somewhere that if you want a C/C++ function to return a character array (as opposed to std::string), you must return const char* rather than char*. Doing the latter may cause the program to crash.
Would anybody be able to explain whether this is true or not? If it is true, why is returning a char* from a function so dangerous? Th...
code below.
i'm tryind to obtain string answers like "a1", "c4"
this is what i'm having instead of "a1": "adresse finale: \340}00\214"
with this prinf:
printf("\nadresse finale: %s",[self convertCGPointToSquareAdress:self.frame.origin]);
the method is:
-(NSString *) convertCGPointToSquareAdress:(CGPoint ) point{
int x= point.x /...
Hi all
I am using a dll written in C++ in a C# application.
What is the equivalent for
char const *
unsigned short
in C#
thanks
...
Hello,
I'm working on a project with JAXB but I run into a small problem with JAXB and the char datatype.
char gender = 'M';
Translates after marshalling into:
<gender>77</gender>
So I think that char is mapped to integer, but I simply want to map it to a String. How can I do this? Is it even possible?
...
It's been a while since I worked on a Linux kernel module, and I seem to remember that there was a place to stash context in your open() open implementation that would be available in your other file_operations... For example, if I want to maintain some state associated with everyone that opens my device node, if either the inode structu...
Is there a function in c that will return the index of a char in a char array?
For example something like:
char values[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char find = 'E';
int index = findInedexOf( values, find );
...
hello,
in my web site, using google language api , i type malayalam language in text box and text area ,
ഇതു ഒരു നല്ല സിനിമ ആണ്
like this, but when i look in to the mySQL database, in the table, it is
ഇതു ഒരു
നല്ല സിനിമ
ആണ&#...
How I can convert LPBYTE to char [256]?
When I read from Windows registry value:
blah REG_SZ "blah some text"
char value[256];
DWORD keytype = REG_SZ;
DWORD dwCount = sizeof(value);
RegQueryValueEx((HKEY)key, "blah", 0, &keytype, (LPBYTE)&value, &count);
cout << "Read text from registry: " << value << endl;
after cout this it shows...
I only have access to 'C' and need to replace characters within a character array. I have not come up with any clean solutions for this relatively simple procedure.
I am passed a character array, for example:
char strBuffer[] = "/html/scorm12/course/course_index.jsp?user_id=100000232&course_id=100000879&course_prefix=ACQ&v...
Trying to copy a char *str to char c[] but getting segmentation fault or invalid initializer error.
Why is this code is giving me a seg fault?
char *token = "some random string";
char c[80];
strcpy( c, token);
strncpy(c, token, sizeof c - 1);
c[79] = '\0';
char *broken = strtok(c, "#");
...
Possible Duplicate:
How to copy char *str to char c[] in C?
char *token = "some random string";
char c[80];
strncpy(c, token, sizeof c - 1);
c[79] = '\0';
char *broken = strtok(c, "#");
...
I want to reinitialize d everytime in a loop
char d[90];
while(ptr != NULL)
{
printf("Word: %s\n",ptr);
//int k = 0;
strcpy(d, ptr);
d[sizeof(d)-1] = '\0';
//something more
....
....
}
...
I am very confused about when to use string (char) and when to use string pointers (char pointers) in C++. Here are two questions I'm having.
which one of the following two is correct?
string subString;
subString = anotherString.sub(9);
string *subString;
subString = &anotherString.sub(9);
which one of the following two is correct?...
Given a string of hex values i.e. e.g. "0011223344" so that's 0x00, 0x11 etc.
How do I add these values to a char array?
Equivalent to say: char array[4] = { 0x00, 0x11 ... };
...
Have an array of chars like char members[255]. How can I empty it completely without using a loop?
char members[255];
By "empty" I mean that if it had some values stored in it then it should not. For example if I do strcat then old value should not remain
members = "old value";
//empty it efficiently
strcat(members,"new"); // should...