Hi all,
Suppose i have a char variable pointer, and i allocated memory using malloc. is it different between using strcpy and assigned value directly to this pointer?
char *s1;
s1 = (char...
Type: Posts; User: unikgila
Hi all,
Suppose i have a char variable pointer, and i allocated memory using malloc. is it different between using strcpy and assigned value directly to this pointer?
char *s1;
s1 = (char...
I mean Malloc doesn't initialize memory to zero, but assigned the value to 0.
int main()
{
int x = ARRAY_SIZE;
int *pa, *pb, *pc, *pd;
pa = malloc(sizeof(int) * x);
pb =...
In this case i know how many values, but suppose i don't know how many values that i have assigned. is there any way to know it?
Because, in my understanding, if i already reserve the memory using...
Hi all,
I have a variable pointer, which i allocate the memory using the malloc command. I want to reverse the order of the variable pointer. But how do i know the last memory address for this?
...
Yes, there are a lot warning when compilation. I ask this because when i compare it with string that you have mentioned it.
Usually i can use
char *x = "hello";
printf("%s \n",x) ==> hello...
still error ==> segmentation fault
ok, i show the code:
int main()
{
int *pa = {1,2,3,4,5,6}
for(j=0; j<5;j++)
{
I follow your code, but i just got
0x1
I want to the whole array in variable can be printed, so the expectation result is
1 2 3 4 5 6
Hi all,
Need explanation how can i print this :
int *pa = {1,2,3,4,5,6};
if i use
printf("%d",pa) ===> result is 1
thanks for both of you :)
Sorry for not understand what you explain :( . If possible, i hope you can give me the sample code or repair the code that i have wrote above. Thanks
You are right, however if i still define
struct a[10];
sizeof(a) == 360
I think my first question still was not answered, because the memory already prepare for 10 variables a
Hi Nonoob,
You mean, i don't need to define variable a[10] instead of just put *a ?
I follow your idea, but i got the 0 result for sumStructs function. I modify my code like this:
...
Dear all,
Suppose i have a program that is consisted of a struct. this struct will be used as an array.
typedef struct
{
char name[30];
int salary;
} person;
Thanks tabstop,
I add second parameter for the number of array in b. it solve the problem. And again thank you for your explanation
Hi tabstop,
I still curious about his, i think when the p point to out of array of b, i this case because i have put
b[] = {2,3,4,2,3,6}, the maximum array that can be pointed by p is b[5], and...
I don't know either, but in my understanding the last array should be the value '\0'. Anyway could you show me the running example for this problem ?
No i want to the *p point to b[0] and then b[1] continue to b[5], i add some printf to show the exactly what the problem
#include <stdio.h>
main(void)
{
int b[] = {2,3,4,2,3,6};
int i;...
Hi all,
I have short program with pointer
#include <stdio.h>
main(void)
{
int b[] = {2,2,2,2,2,2};