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...
Hi, I was looking for a way to convert an integer to a string in a portable manner (portable among at least Windows & Linux and x86 and x86_64) and I though itoa(X) to be standard just like atoi(1).
But I read the following in the Wikipedia entry:
The itoa function is a widespread non-standard extension to the standard C programmin...
I have the following homework question:
Consider the following declarations and answer the question.
char strarr1[10][32];
char *strarr2[10];
Are strarr1[3][4] and strarr2[3][4] both legal references?
I tried compiling the code with gcc to test it. I was fairly sure that the second reference would throw an error, but it didn't. This ...
I'm really confused by this unicode vs multi-byte thing.
Say I'm compiling my program in Unicode (but ultimately, I want a solution that is independent of the character set used).
1) Will all 'char' be interpreted as wide characters?
2) If I have a simple printf statement, i.e. printf("Hello World\n"); with no character strings, can I...
I'm grading C and C++ files for a class, and this assignment uses the GSL library. Since I don't have root permission on my computer, my GSL library is installed in my home directory, and thus I need to tell compilers and linkers where to find it.
This isn't a problem when I write a program myself, because I just add the appropriate -L...
Hi,
I am confused about this code: (http://www.joelonsoftware.com/articles/CollegeAdvice.html)
while (*s++ = *t++);
What is the order of execution? Is *s = *t first done, and then are they each incremented? Or other way around?
Thanks.
EDIT: And what if it was:
while(*(s++) = *(t++));
and
while(++*s = ++*t);
...
Does C++ code gets converted to C before compilation ?
...
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...
I have a number of data sets that have key-value pattern - i.e. a string key and a pointer to the data. Right now it is stored in hashtables, each table having array of slots corresponding to hash keys, and on collision forming a linked list under each slot that has collision (direct chaining). All implemented in C (and should stay in C)...
Can anyone explain why I am getting segmentation fault in the following example?
#include <stdio.h>
#include <string.h>
int main(void) {
char *hello = "Hello World, Let me live.";
char *tokens[50];
strtok_r(hello, " ,", tokens);
int i = 0;
while(i < 5) {
printf("%s\n", tokens[i++]);
}
}
...
I'm using a char[] of size 4 but when I use memcpy() function it stores 8 characters in it and also the character array length becomes 8. What is happing?
I don't want to use malloc ok.
char strRoh[4]={'\0'};
and then
memcpy(strRoh,Dump+22,4);
Now tell me whats wrong with this
char strIP[]="hhhhhhhh";
char strRoh[4]={'\0'};
char ...
hi there
i am writing a program in C and i wanna know how can i listen on com port
and read the data from it
please help me
thanks
...
I have two png images First one with Width1 2247 Height1 190 and second one with Width2 155 Height2 36. I wan't the second image(src) to be placed in the center of first image(dest). I created pixel buf of both and used gdk_pixbuf_composite as follows.
gdk_pixbuf_composite( srcpixbuf, dstpixbuf, 1000, 100, width2, height2, 0, 0, 1, 1, G...
Hi all,
I'm using Visual Studio .NET 2003, and I'm trying to convert a program written in purely ANSI characters to be independent of Unicode/Multi-byte characters.
The program has a callback function of pcap_loop, called "got_packet". It's defined as
void got_packet(u_char *user, const struct pcap_pkthdr *header, const u_char *cpacke...
I want to archive my database of mysql. Kindly give me some guide lines how I can make it possible, I am using mysql c library for insertion and selection etc. I dont know how to use dump command.
...
I need to introduce basic design principles in my team. I am looking for books which are not restricted to only object oriented design principles. And which can cover concepts such as Modularity, Information hiding etc.
Just for information - The implementation language for all the project in our team is C.
...
Hi,
I am facing a weird problem. While browsing the C code of a project, the "Find this text string:" output results in a positive match, but the text is invisible [only the search results are invisible and not the menu]. The cursor moves up and down the list of results. Some of the lines are visible sometimes as you can see in the scre...
After reading the docs, it seems the the function sqlite3_column_count does all the same, but doesn't have the restrictions that sqlite3_data_count has.
Why would I ever want to use sqlite3_data_count over sqlite3_column_count? thanks!
...
How can I read from the stdout of my program?
One of my threads needs to access the stdout to read what the other threads are logging.
I'm using the dear old plain C.
...
qsort(bt->rw[t], bt->num[t],
sizeof(TRELLIS_ATOM *),
(int (*)(const void *,const void *))compare_wid);
bt->rw[t] is a pointer to struct pointer, bt->[num] is an int, I don't understand what that fourth parameter is, except that compare_wid is a function defined somewhere as follows:
static int compare_wid( TRELLIS_ATOM* ...