Mar!o
I see if you write *parr[i]
Mar!o
Its the same as *(*(parr + i))
Javi
..?
parr[i] is a pointer
Javi
What happens if you add * in front?
Javi
Not remotely the same
Mar!o
No again
Why not?
Anonymous
What happens if you add * in front?
pointer pointing to pointer
Javi
Why not?
Read about pointers and arrays
Mar!o
a[i] is *(a + i) i[a] is *(i + a)
Javi
What happens when you put a * before a pointer? What do you get?
Mar!o
No again
Of course it is
Javi
The value
He is trying to learn
Mar!o
I see...
Mar!o
What is:
MengShu
I suggest looking at how Javi helps Bucky think about how pointer works.
Anonymous
it print adress of these 3 arr
Anonymous
it print 1 0 1
Javi
it print adress of these 3 arr
Because parr is an array of ints
Javi
So, when you add * in front, what are you doing?
Javi
I think that you have a basic problem with pointers. I suggest you to read how they work and what is their relationship with arrays
Anonymous
kk
Anonymous
Anonymous
check out the defination I understood
Anonymous
Another perfectness of C (the God programming language). when you say: int *(*p[10])(int); then the type of: *(*p[inex])(arg) is int so the type of: (*p[index])(arg) is pointer to int or int * so the type of *p[index] is a function which return pointer to an int with an argument of type int so the type of p[index] is a pointer to that function so the type of p is an array of pointers to function
Mar!o
C is God's programming language
Mar!o
Terry Davis prooved it
Wisenky
#include "stdio.h" #include "stdlib.h" #include "string.h" #include "math.h" typedef struct { int size,id,tip; float x1,x2,y1,y2; }blocks; int main() { blocks *block1 , *block2 , *block3; char line[60]; int blcNum=1, sizer=0, temp; block1 = malloc( sizeof(blocks) ); block2 = malloc( sizeof(blocks) ); block3 = malloc( sizeof(blocks) ); FILE *fp; fp = fopen("IEEE_test_system_12.txt","r"); while(!feof(fp)){ fgets(line,60,fp); if ( strstr(line,"\0") != NULL && strstr(line,"ID") == NULL && strstr(line,"END") == NULL ) { sizer++; printf(line); } else if ( strstr(line,"END") != NULL ){ if ( blcNum == 1){ block1->size = sizer,blcNum++,sizer = 0; } else if ( blcNum == 2){ block2->size = sizer,blcNum++,sizer = 0; } else if ( blcNum == 3){ block3->size = sizer,blcNum++,sizer = 0; } } }; block1 = realloc(block1 , block1->size * sizeof(blocks)); block2 = realloc(block2 , block2->size * sizeof(blocks)); block3 = realloc(block3 , block3->size * sizeof(blocks)); fclose(fp); line == NULL,blcNum = 1; fp = fopen("IEEE_test_system_12.txt","r"); for ( temp =0 ; temp < block1->size ; ++temp) { while(!feof(fp)){ fgets(line,60,fp); if ( strstr(line,"ID") == NULL && strstr(line,"END") == NULL && strstr(line,"\0") != NULL) { if ( blcNum == 1){ fscanf(fp,"%d %.2f %.2f",&(block1+temp)->id,&(block1+temp)->x1,&(block1+temp)->y1); } else if ( blcNum == 2){ fscanf(fp,"%d %d %.2f %.2f %.2f %.2f",&(block2+temp)->id,&(block2+temp)->tip, &(block2+temp)->x1,&(block2+temp)->y1, &(block2+temp)->x2,&(block2+temp)->y2); } else if ( blcNum == 3){ fscanf(fp,"%d %.2f %.2f %.2f %.2f",&(block3+temp)->id,&(block3+temp)->x1, &(block3+temp)->y1,&(block3+temp)->x2, &(block3+temp)->y2); } } else if ( strstr(line,"END") != NULL ){ blcNum++; } } } fclose(fp); printf("\nUploader's information : \n"); for (temp =0; temp < block1->size ; ++temp) { printf(" id : %d , X1 : %.2f , Y1 : %.2f \n",(block1+temp)->id,(block1+temp)->x1,(block1+temp)->y1); } printf("\ncustomer's information : \n"); for (temp =0; temp < block2->size ; ++temp) { printf(" id : %d , tip : %d , X1 : %.2f , Y1 : %.2f , X2 : %.2f , Y2 : %.2f \n",(block2+temp)->id,(block2+temp)->tip,(block2+temp)->x1, (block2+temp)->y1,(block2+temp)->x2,(block2+temp)->y2); } printf("\nLine's information : \n"); for (temp =0; temp < block3->size ; ++temp) { printf(" id : %d , X1 : %.2f , Y1 : %.2f , X2 : %.2f , Y2 : %.2f \n",(block2+temp)->id,(block2+temp)->x1, (block2+temp)->y1,(block2+temp)->x2,(block2+temp)->y2); } printf("\n1 . block's size : %d ",block1->size); printf("\n2 . block's size : %d ",block2->size); printf("\n3 . block's size : %d ",block3->size); free(block1); free(block2); free(block3); return 0; }
Wisenky
#include "stdio.h" #include "stdlib.h" #include "string.h" #include "math.h" typedef struct { int size,id,tip; float x1,x2,y1,y2; }blocks; int main() { blocks *block1 , *block2 , *block3; char line[60]; int blcNum=1, sizer=0, temp; block1 = malloc( sizeof(blocks) ); block2 = malloc( sizeof(blocks) ); block3 = malloc( sizeof(blocks) ); FILE *fp; fp = fopen("IEEE_test_system_12.txt","r"); while(!feof(fp)){ fgets(line,60,fp); if ( strstr(line,"\0") != NULL && strstr(line,"ID") == NULL && strstr(line,"END") == NULL ) { sizer++; printf(line); } else if ( strstr(line,"END") != NULL ){ if ( blcNum == 1){ block1->size = sizer,blcNum++,sizer = 0; } else if ( blcNum == 2){ block2->size = sizer,blcNum++,sizer = 0; } else if ( blcNum == 3){ block3->size = sizer,blcNum++,sizer = 0; } } }; block1 = realloc(block1 , block1->size * sizeof(blocks)); block2 = realloc(block2 , block2->size * sizeof(blocks)); block3 = realloc(block3 , block3->size * sizeof(blocks)); fclose(fp); line == NULL,blcNum = 1; fp = fopen("IEEE_test_system_12.txt","r"); for ( temp =0 ; temp < block1->size ; ++temp) { while(!feof(fp)){ fgets(line,60,fp); if ( strstr(line,"ID") == NULL && strstr(line,"END") == NULL && strstr(line,"\0") != NULL) { if ( blcNum == 1){ fscanf(fp,"%d %.2f %.2f",&(block1+temp)->id,&(block1+temp)->x1,&(block1+temp)->y1); } else if ( blcNum == 2){ fscanf(fp,"%d %d %.2f %.2f %.2f %.2f",&(block2+temp)->id,&(block2+temp)->tip, &(block2+temp)->x1,&(block2+temp)->y1, &(block2+temp)->x2,&(block2+temp)->y2); } else if ( blcNum == 3){ fscanf(fp,"%d %.2f %.2f %.2f %.2f",&(block3+temp)->id,&(block3+temp)->x1, &(block3+temp)->y1,&(block3+temp)->x2, &(block3+temp)->y2); } } else if ( strstr(line,"END") != NULL ){ blcNum++; } } } fclose(fp); printf("\nUploader's information : \n"); for (temp =0; temp < block1->size ; ++temp) { printf(" id : %d , X1 : %.2f , Y1 : %.2f \n",(block1+temp)->id,(block1+temp)->x1,(block1+temp)->y1); } printf("\ncustomer's information : \n"); for (temp =0; temp < block2->size ; ++temp) { printf(" id : %d , tip : %d , X1 : %.2f , Y1 : %.2f , X2 : %.2f , Y2 : %.2f \n",(block2+temp)->id,(block2+temp)->tip,(block2+temp)->x1, (block2+temp)->y1,(block2+temp)->x2,(block2+temp)->y2); } printf("\nLine's information : \n"); for (temp =0; temp < block3->size ; ++temp) { printf(" id : %d , X1 : %.2f , Y1 : %.2f , X2 : %.2f , Y2 : %.2f \n",(block2+temp)->id,(block2+temp)->x1, (block2+temp)->y1,(block2+temp)->x2,(block2+temp)->y2); } printf("\n1 . block's size : %d ",block1->size); printf("\n2 . block's size : %d ",block2->size); printf("\n3 . block's size : %d ",block3->size); free(block1); free(block2); free(block3); return 0; }
why I can not print values truely ?
Huzefa
https://t.me/NetflixPremiumGenBot?start=r0892602806
Noble Friend
#include "stdio.h" #include "stdlib.h" #include "string.h" #include "math.h" typedef struct { int size,id,tip; float x1,x2,y1,y2; }blocks; int main() { blocks *block1 , *block2 , *block3; char line[60]; int blcNum=1, sizer=0, temp; block1 = malloc( sizeof(blocks) ); block2 = malloc( sizeof(blocks) ); block3 = malloc( sizeof(blocks) ); FILE *fp; fp = fopen("IEEE_test_system_12.txt","r"); while(!feof(fp)){ fgets(line,60,fp); if ( strstr(line,"\0") != NULL && strstr(line,"ID") == NULL && strstr(line,"END") == NULL ) { sizer++; printf(line); } else if ( strstr(line,"END") != NULL ){ if ( blcNum == 1){ block1->size = sizer,blcNum++,sizer = 0; } else if ( blcNum == 2){ block2->size = sizer,blcNum++,sizer = 0; } else if ( blcNum == 3){ block3->size = sizer,blcNum++,sizer = 0; } } }; block1 = realloc(block1 , block1->size * sizeof(blocks)); block2 = realloc(block2 , block2->size * sizeof(blocks)); block3 = realloc(block3 , block3->size * sizeof(blocks)); fclose(fp); line == NULL,blcNum = 1; fp = fopen("IEEE_test_system_12.txt","r"); for ( temp =0 ; temp < block1->size ; ++temp) { while(!feof(fp)){ fgets(line,60,fp); if ( strstr(line,"ID") == NULL && strstr(line,"END") == NULL && strstr(line,"\0") != NULL) { if ( blcNum == 1){ fscanf(fp,"%d %.2f %.2f",&(block1+temp)->id,&(block1+temp)->x1,&(block1+temp)->y1); } else if ( blcNum == 2){ fscanf(fp,"%d %d %.2f %.2f %.2f %.2f",&(block2+temp)->id,&(block2+temp)->tip, &(block2+temp)->x1,&(block2+temp)->y1, &(block2+temp)->x2,&(block2+temp)->y2); } else if ( blcNum == 3){ fscanf(fp,"%d %.2f %.2f %.2f %.2f",&(block3+temp)->id,&(block3+temp)->x1, &(block3+temp)->y1,&(block3+temp)->x2, &(block3+temp)->y2); } } else if ( strstr(line,"END") != NULL ){ blcNum++; } } } fclose(fp); printf("\nUploader's information : \n"); for (temp =0; temp < block1->size ; ++temp) { printf(" id : %d , X1 : %.2f , Y1 : %.2f \n",(block1+temp)->id,(block1+temp)->x1,(block1+temp)->y1); } printf("\ncustomer's information : \n"); for (temp =0; temp < block2->size ; ++temp) { printf(" id : %d , tip : %d , X1 : %.2f , Y1 : %.2f , X2 : %.2f , Y2 : %.2f \n",(block2+temp)->id,(block2+temp)->tip,(block2+temp)->x1, (block2+temp)->y1,(block2+temp)->x2,(block2+temp)->y2); } printf("\nLine's information : \n"); for (temp =0; temp < block3->size ; ++temp) { printf(" id : %d , X1 : %.2f , Y1 : %.2f , X2 : %.2f , Y2 : %.2f \n",(block2+temp)->id,(block2+temp)->x1, (block2+temp)->y1,(block2+temp)->x2,(block2+temp)->y2); } printf("\n1 . block's size : %d ",block1->size); printf("\n2 . block's size : %d ",block2->size); printf("\n3 . block's size : %d ",block3->size); free(block1); free(block2); free(block3); return 0; }
hmm. which language is that?
Noble Friend
C
no angled brackets at the place of #include ? (the greater and less than signs>
Noble Friend
ok boss. i just kind of beginner so that's what i noticed. i hope you find your solution here buddy
Wisenky
someone who has stackover acc would vote up this —> https://stackoverflow.com/questions/60812715/how-to-access-which-values-are-put-in-struct-truely
Javi
check out the defination I understood
The key thing that you have to remember is that arrays (no matter the dimensionality) are just pointers in disguise
Wisenky
i saw the problem, bro :))
hey sir someone reps this and says !feof crushes something
Dima
Bruh
Hubert
the troubles caused by fgets and fscanf at the same time, therefore the line is not correct
Wisenky
the troubles caused by fgets and fscanf at the same time, therefore the line is not correct
well I have to bully with cripple functions as if not enough my low-level C-knowledge
Wisenky
lol
Anonymous
/warn offtop
Dima
bruh
Mar!o
😂😂
MilkBeforeCereal
bruh
it's fairly common Indian name lul
I_Interface
bruh
lmao
Daniel
Guys ,I need someone’s help....
Daniel
Daniel
Why the programming is stuck there.
I_Interface
Why the programming is stuck there.
U forgot & for gender.
Daniel
But gender is a array
I_Interface
Okay. Why do u need God damn array for 1 symbol ?
Daniel
.... I am just practicing
Daniel
😂for a symbol?
Daniel
I just add &before gender
Daniel
But it also doesn’t work
I_Interface
I just add &before gender
It doesnt need, i checked. In this case u don't need an array.
I_Interface
Just use char variable.
Ashish Bhushan
bruh
😂😂😂
Daniel
But why array can’t work,,,
Daniel
I’m just curious about that
Ashish Bhushan
Array can work but you have mixed the concept of array and a single variable
Ashish Bhushan
And also here we dont need an array
Ashish Bhushan
Coz at a time gender variable will store only one value... No need of array
Ashish Bhushan
Also you syntax is wrong for taking input of gender!!!!
Daniel
Thanks dude
Ashish Bhushan
Np😊
Daniel
Also you syntax is wrong for taking input of gender!!!!
One more thing man ,What is the wrong syntax i made😂
Ashish Bhushan
You have declared an array for gender... And while taking input you have written it as gender but it should be with a loop for ex. For(i=0;i<2;i++) Scanf("%c",gender[i]);
Ashish Bhushan
Although it's wrong... Coz you don't need an array😂😂