C++ Expression must have pointer-to-object type

You probably meant: since c_info is an array, by doing c_info[i] you’ll access the i-th instance (object) of Employee class in c_info array, and then obtain hoursWorked through . operator. Now you can clearly see that your variant simply doesn’t make sense, as hoursWorked is just an integral type and not an array, and therefore … Read more

strcmp giving segmentation fault

The above statement defines get to be a pointer to a character. It can store the address of an object of type char, not a character itself. The problem is with both scanf and strcmp call. You need to define an array of characters to store the input string.

Is the sizeof(some pointer) always equal to four?

he guarantee you get is that sizeof(char) == 1. There are no other guarantees, including no guarantee that sizeof(int *) == sizeof(double *). In practice, pointers will be size 2 on a 16-bit system (if you can find one), 4 on a 32-bit system, and 8 on a 64-bit system, but there’s nothing to be gained in … Read more

Warning: return from incompatible pointer type in C

Well, yes? The function is declared to return char *, but you return i1 which is the input argument and has type int *. You might mean to return the newly allocated string dum, and perhaps also fill it with the data that was read using fgets() to the separate character array input. In this case, you need to copy the data over, … Read more

Pointers in Python?

I want form.data[‘field’] and form.field.value to always have the same value This is feasible, because it involves decorated names and indexing — i.e., completely different constructs from the barenames a and b that you’re asking about, and for with your request is utterly impossible. Why ask for something impossible and totally different from the (possible) thing you actually want?! Maybe you don’t realize how drastically different barenames and decorated … Read more

Reversing a string in C

If you want to practice advanced features of C, how about pointers? We can toss in macros and xor-swap for fun too! A pointer (e.g. char *, read from right-to-left as a pointer to a char) is a data type in C that is used to refer to location in memory of another value. In this case, the location where … Read more

Delete 2D array C++

delete [] *M; is the same as delete [] M[0], so it is not equivalent to deleting all M[i] in a loop because only the first one would be deleted. The loop is the correct way to avoid memory leaks. Or better, use std::vector instead of manual allocations and you won’t need to worry about deleting pointers.

Sorting Linked List C++ with pointers

I have been struggling for hours on end with this problem. My goal is to sort a linked list using only pointers (I cannot place linked list into vec or array and then sort). I am given the pointer to the head node of the list. The only methods i can call on the pointers … Read more

Constant pointer vs Pointer to constant

declares ptr a pointer to const int type. You can modify ptr itself but the object pointed to by ptr shall not be modified. While declares ptr a const pointer to int type. You are not allowed to modify ptr but the object pointed to by ptr can be modified. Generally I would prefer the declaration like this which make it easy to read and understand (read from right to left):

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)