Anonymous
a is pointer to first element
Aakash
int a[]; int *p=a; std::cout«a«std::endl;
In simple terms; Array == Storage Pointer == Location/Address of Storage.
Anonymous
a is pointer to first element
No, it's an array
Vlad
int a[]; int *p=a; std::cout«a«std::endl;
Pointer is just an address of single element
Anonymous
if im in 1d array , arr behave as pointer
Anonymous
Read the message as many times as you need to understand it https://t.me/programminginc/366386
Anonymous
Anonymous
just tell me the difference like if i point a pointer to array then difference between array and that pointer
Anonymous
except size
Anonymous
you r considering functions
void foo(int arr[]) Arr is not array, it's a pointer declared with array syntax
Vlad
huh
int(*)[10]
Anonymous
if i point a pointer to array then if i use array or pointer no differ (1d array)
Anonymous
int array[20]; using pointer_t = int (*)[20]; pointer_t arr_ptr = & array;
Vlad
if i point a pointer to array then if i use array or pointer no differ (1d array)
You pass arrays as pointers because there's no "by value" semantic for arrays in C
Pavel
Hey, I have a question for yous. I have limited experience of programming in general. Just little scripts here and there to solve problems. I am good with basics of c++ and now I want to dive deeper. I believe a good practice would be to start studying some open source app and learn how they coded it to get a sense of it. My problem is, I don't even know how to read some open source app. It's just so much of code (even small projects) for me to get started with. Do you have any tips on how do you READ someone's code to understand how they developed that app. For example, let's say implementation of "ls" command on Linux.
Unfortunately there's no definitive guide to reading projects code, since there are too many ways to build app architecture and even in the same field you can find dozens of "common" patterns. And without knowing these patterns it can be really hard to understand what the code is actually doing (sometimes even with debugger). It can be frustrating to read such code and then find out that you've spent lot of time on investigating some helper code that is not particularly interesting to the app. What I can suggest in a case you open an app and can't understand where to even start looking: you can try to find some documentation. Second, you can find communities or discussion groups about this project and ask there about where to start and where to look at some things (like you would do when you get to work on a new project). If the project is small, you can ask the developers themself for advices about where to look to find something that you're interested in. And also you can find unit/auto tests and look at their code, sometimes they can provide a lot of insides of how specific systems work. Also there are many articles on the internet (and even a book I see) on the topic of reading code, I suggest to read some of those to get some insights.
Anonymous
thnku guys :)
Aakash
Unfortunately there's no definitive guide to reading projects code, since there are too many ways to build app architecture and even in the same field you can find dozens of "common" patterns. And without knowing these patterns it can be really hard to understand what the code is actually doing (sometimes even with debugger). It can be frustrating to read such code and then find out that you've spent lot of time on investigating some helper code that is not particularly interesting to the app. What I can suggest in a case you open an app and can't understand where to even start looking: you can try to find some documentation. Second, you can find communities or discussion groups about this project and ask there about where to start and where to look at some things (like you would do when you get to work on a new project). If the project is small, you can ask the developers themself for advices about where to look to find something that you're interested in. And also you can find unit/auto tests and look at their code, sometimes they can provide a lot of insides of how specific systems work. Also there are many articles on the internet (and even a book I see) on the topic of reading code, I suggest to read some of those to get some insights.
If one cannot compile “ls” command, and also don’t know how to compile or map its dependencies with ls-command; ..forget about reading advance code; even writing advance code is way beyond. Basically oneself need to know basic about how compiler works! And what are the dependencies to the code; Then map advance codes. 🙃
Pavel
Thank you. So would you haave any suggestions for open source apps that I can start studying? Assuming that you'd have done it at some point yourself.
I don't think I have something in mind, I mostly investigated private repos I worked on, and some very specific things like Recast/Detour, Entt, PolyPartition. I don't think I can suggest any of those as a good example
Nish
get an ide where links between multiple files work and start intensely staring at the code. you'll understand eventually.
Thanks. Any suggestions? For now, I just use vim for everything. Also, any suggestions for any program that is relatively smaller to "read"?
Anonymous
Thanks. Any suggestions? For now, I just use vim for everything. Also, any suggestions for any program that is relatively smaller to "read"?
> use vim for everything anything is fine as long as you can interact with struct, function, enum, and header names and reach their sources instantly. > smaller to "read" idk about small, but i started with reading parts of systemd because i wanted to know how some annoying things there worked
Anonymous
Lol about systemd. So I guess some ide where you could just click on the structs and function definitions to understand where they lead.
yes. complexity is just a staring contest. you'll understand the function eventually, no matter how complex.
Anonymous
Lol about systemd. So I guess some ide where you could just click on the structs and function definitions to understand where they lead.
oh and for intentionally esoteric code (e.g. obfuscated c contest), put it through clang-format and half your work will be done
Nish
😂
Anonymous
Does any one know how I can customise xfce4 logout menu icons? After updating to version 4.16, they look terrible
Roxifλsz 🇱🇹
Does any one know how I can customise xfce4 logout menu icons? After updating to version 4.16, they look terrible
Absolutely not a question for this group, but I usually solve this problem by installing KDE :^)
Divyanshi
Does anyone have coding blocks' algo++ and competitive programming course?
Divyanshi
Please share🙏
PO
Hi
PO
how are you guys?
PO
I need help! How can I remove a line from a file which begins with '#' ? for example : #This is a line to be removed
Asad
Read the whole file to some collection. As you iterate over it, remove lines starting with hashtag
Anonymous
1. Read all lines in an array 2. Find and remove lines you need to be deleted 3. Rewrite the file
PO
how should I find and remove it?
telegram
#include<stdio.h> #include<stdbool.h> struct node { int data; struct node *next; }; struct node *head; void printlist(struct node *p){ while(p != 0 || p!=NULL){ printf("%d",p->data); printf("hell"); p = p->next; } } int main() { int c; bool yes = true; struct node *add; while(yes) { add = (struct node *)malloc(sizeof(struct node)); scanf("%d",&add->data); head = add; printf("enter n for stopiing\n"); scanf("%c",&c); if( c == 'n'){ printlist(head); } } return 0; }
telegram
Can anyone explain why my list is not iterating
telegram
Don't be selfish try to answer me
[BLĀNK]
Lol, wait i am reading, btw i am still a noob in comparison to others so..
telegram
Read
[BLĀNK]
Can you mention the error?
[BLĀNK]
Or just the output isn't correct?
telegram
3 enter n for stopiing 4 enter n for stopiing 5 enter n for stopiing 6 enter n for stopiing n enter n for stopiing 0hell
Nish
Don't be selfish try to answer me
Lol... How does one even..
[BLĀNK]
how should I find and remove it?
Find the character '#' Start removing the characters one by one until you reach the character ' '(space)
[BLĀNK]
And?
[BLĀNK]
A bit more details please 😅
[BLĀNK]
Okay, So every line ends with a '\n' Now keep track of which line you are in, Now, after you get to next line, check is the current/first character is '#' If yes, then join the previous line with the next line E.g: 1 2 # 3 Join 1 and 3
[BLĀNK]
Over all the whole thing is a big fat array
[BLĀNK]
So functions like string division or string concatenation will do
[BLĀNK]
the nodes that you trying to create aren't linked
Also, i would recommend you to have separate struct node to traverse the list with ease, and also foe adding new elements to the link list
[BLĀNK]
Lol, not u😂
MRT
anybody worked with psql in c ++ ?
MRT
how i can get table data in c++ with PQexec