It's easier if you put the types of the variables too. From what you have above, I think that you have this:
int value = 25; // A variable that you implied was equal to 25
int *beth; // A pointer to an integer
int *ted = &value; // A pointer to an integer, initialised to the address of value
beth = ted; // This is OK, they're both pointers
beth = *ted; // This isn't OK, a pointer stores a memory address, not an int value
beth = &ted; // This isn't OK, a "pointer to a pointer" is not the same as a "pointer to a double"
I thing program will be compile but can not direct assign the address of variable .
The two lines that I indicated as not OK should produce compile-time errors, so the program shouldn't compile. From the compiler's point of view, on line 6, you're trying to assign a variable of type int to one of type int * , so this shouldn't be allowed. And, on line 7, you're trying to assign a variable of type int ** to one of int * , so this shouldn't be allowed either.
I don't know how consistent different compilers are with this kind of implicit type-casting, but I can't imagine it's a good idea. If you need to make an assignment like this, then you can explicitly specify the type-cast, as in
beth = (int *)(&ted);
It will compile, but I'm not sure if it will produce a well-defined result?
I am writing a java program that needs to execute shell commands, so I wrote a function that would take the command to execute as a string (ie: "mkdir ~/Folder1") and execute that command with the shell. Here is the function:
Runtime run = Runtime.getRuntime();
Process pr = ...
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.