struct name *p;
n = (char *)malloc(3 * sizeof(char)); // in this why 3 means.. its my condition
n = (char *)p;
n->a = 3; // this line is showing error why?
/////// This is my outline of my program .......Doubt is wheter we can assign character pointer to structure pointer.......if its true means why the last line is showing error can anyone solve this fully upto n and print..............other condition is we have to give value for structure not by user.......
OK you CAN assign a structure pointer to a char point but it is not a terribly good idea and doesn't serve any good purpose on the whole.
On your malloc line you assign a value to n, it points at some allocated data.
Then on the next line you assign to n the value of p. Firstly this is a memory leak, you have just lost the pointer to the allocated memory and no-longer have any means to free it. Secondly p is not initialised to anything and strictly speaking using an uninitialised automatic scope variable is undefined behaviour.
Then you try n->a . N is a char pointer, it has no members, *n is a char. You could use p->a but p does not have a valid value yet.
I don't know what you are trying to achieve but I suspect you want something more like
struct name* p;
p = malloc(sizeof *p);
p->a = 3;
/* More code here */
/* Now I have finished with p */
write a C++ program which take inputs from the user/keyboard and calculate his ZAKAT.
get the input from user may include
-Amount invested in business
-Amount given to other business partners as loan
-Amount payable to others
I made a prime number finder, it finds the nearest prime that is above and below any integer (Does not work that well with giant numbers.)
Made this in cpp.sh
Why would I need the x=y+1-1;?
x=y; just doesnt seem to work
Why is this?
And I know my coding ...
there are five tables (personTb, addressTb,churchTb) each holds data pertinent to an individual; (personAddress,personChurch) each hold the primary key for the person table and corresponding table IE personAddress holds primary key for addressTb.
both snippets work, my question is; Is my join correctly formatted?