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 */
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...
Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...