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

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

get Index of last Element in list without using lastIndexOf() or any other Java/String- Methods [closed]

The below code works in getting the last index of a certain character: public int lastIndex(char a, char[] data) { int max=-1; for(int i=0; i<data.length; i++) { if(data[i]==a) { max=i; } } return max; } It works by going through the array and finding the latest occurrence of a certain character. The variable ‘max’ is … Read more

How to get the + – / * from char

C# doesn’t have a built-in way of handling symbols at run-time. Not every language out there is LISP 🙂 In the general case, you’re talking about a compiler – something that takes code as input, and produces executable. There’s many ways to invoke the C# compiler in C#, and they’re very easy to find, so … Read more