[Solved] Pointers and char[] in C [closed]

To know how all these three code blocks works, you got to start reading good C book specially array and pointers concept. Case 1 :- In the below code block int main(void) { char x[] = “gate2011”; char *ptr = x; printf (“%s”, ptr+ptr[3]-ptr[1]); return 0; } It looks like x[0] x[1] x[2] x[3] x[4] … Read more

[Solved] Comparing two Sub-Strings of two Strings between two set positions (integer values) in C [closed]

You can use the strncmp function to compare two strings up to a maximum number of characters. To start a comparison in the middle of a string, you would pass in the address of the array element to start the comparison at. For example: if (strncmp(&string1[4], &string2[4], 4) == 0) { printf(“characters 5 – 8 … Read more

[Solved] Malloc , Realloc , Memset : Struct pointers , arrays of char, int

Error was in v_push_back implementation : v->e_array = check_a(memcpy((void*)((char*)v->e_array + (v->no_e * v->e_sz)) ,new_val, v->e_sz)); //pointer has not to be saved check_a(memcpy((void*)((char*)v->e_array + (v->no_e * v->e_sz)) ,new_val, v->e_sz)); Because memcpy returns a pointer , in this case, to the last element of the array so we would have lost access to all previous memory solved … Read more