difficulty in understanding how pointers work in c [duplicate] - c

This question already has answers here:
What are the barriers to understanding pointers and what can be done to overcome them? [closed]
(28 answers)
Closed 5 years ago.
I am learning c language for over a year now. But I still don't understand how pointers work. Can anyone suggest a good online resource to make concepts clear.

There is vast number of sources regarding C pointers. You can google for it. Try to read a few, one of them may just click.
Here just few which I like:
https://boredzo.org/pointers/
https://en.wikibooks.org/wiki/C_Programming/Pointers_and_arrays
https://users.cs.cf.ac.uk/Dave.Marshall/C/node10.html
https://en.wikipedia.org/wiki/Pointer_(computer_programming)
https://www.geeksforgeeks.org/function-pointer-in-c/

If you are clear with your concepts of pointers in one language, it would mean that you are clear in all possible programming languages as it is one of the most fundamental concepts.
Geeks for Geeks : More reliable source to clear basic concepts
https://www.geeksforgeeks.org/pointers-in-c-and-c-set-1-introduction-arithmetic-and-array/
Hackerrank is a good source for practical knowledge
https://www.hackerrank.com/challenges/c-tutorial-pointer/problem
Tutorials Point is yet another saviour
https://www.tutorialspoint.com/cprogramming/c_pointers.htm

Related

Is there a shell for quickly experimenting in C? [duplicate]

This question already has answers here:
Is there an interpreter for C? [closed]
(13 answers)
Closed 7 years ago.
I'm not looking for csh, I'm looking for a shell for C similar to the Python or the Scala shells.
I understand that C is a compiled language, but is there anything out there that would let me quickly play around with things so I can e.g. better learn how pointers work? It should at least be theoretically possible to do this, wondering if anyone has taken the time to implement it.
As you well know that C is a compiled language. It is better to write C code than compile it, do some breakpoints, learn what value is in memory, where the pointer points etc.
But I think you mean this. Is there an interpreter for C?

Ruby programmer wants to help a C novice to refactor his small C app [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
A friend of mine needs to learn programming C in school, but unfortunately he has troubles with it and his teacher seems to be pretty incapable, for example, they are using Eclipse IDE and the teacher never showed how to do a Refactor => Rename, for example (so all pupils search and replace stuff manually when they need to).
I promised my friend to help him optimize (fortunately running) app which he copy&pasted with trial&error for hours now. But since I'm a Ruby programmer for years now and touched C/C++ only for a few weeks in a programmer's beginner course about 10 years ago myself, the world of non-OO C is totally unknown for me.
So I would really appreciate some good advice on how to refactor the following small app:
http://speedy.sh/Vnfnw/Energie.zip
It basically reads a CSV (energy/heat values?), computes some stuff, and then prepares some data which should later be sent to GNUplot.
For example, I'm unsure about this:
Is it good practice to send variables into a function as pointers and manipulate them within the function body? From and OOP, I'm used to be very careful with such things and try to change variables only by sending them to some method and assigning the method's return value to the variable again, e.g. x = sum(x, y) (or with ! methods).
I'm sure there is a lot more to optimize in the code. I'm thankful for some basic hints on how to optimize the code. It doesn't have to be perfect, but it's quite a mess at the moment, and before refactoring it into the "wrong" direction, it would be nice to get some feedback here.
Thank you.
"Is it good practice to send variables into a function as pointers and manipulate them within the function body?"
If you need to change them (pass by reference) there is no other way in C. It is a standard way. Also, there are no methods. Only functions. Although you can model OOP by structs and function pointers, for the small program it is not worth it.
You just must be much more attentive when programming in C as any wrong pointer can lead the whole application to crash.
Also I advise your friend to write program by himself and not refactor copy-paste code. From my point of view, the success of refactoring lays in understanding the program much more than on knowing where is "Refactor" menu item.

c pointers, Anyone got fundamental issues? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
What do people find difficult about C pointers?
New to c programming (Actually new to programming in general). Well, I just can't get familiar with c pointers. maybe, I can use them in some situations, but really am stuck to understand it. Anyone been in such a situation? Any suggestions?
I would start at the Introduction to pointers. The link is to a very simple, concise, and easy to follow tutorial/e-learning site. The next chapter goes more in depth. I think you'll find the information helpful in getting a better understanding of how pointers work.
That site discusses things that can confuse people easily. Such as the following syntax differences:
1 int *pnPtr; // a pointer to an integer value
2 double *pdPtr; // a pointer to a double value
3
4 int* pnPtr2; // also valid syntax
5 int * pnPtr3; // also valid syntax
Take a look at What do people find difficult about C pointers?. people discussed what fundamental issues they ran into when trying to learn c pointers.

Algorithm and data structure implementations for C programmers [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Are there any open source C libraries with common data structures?
What is the best source of algorithm and data structure implementations for C programmers? Links to an open source library or a book will do. (Please don't point to Sedgewick, as I already have his book).
Though I have not used GDSL ( Generic Data Structures Library ) I think it's worth considering as it implements many frequently used data structures.
The Algorithm Design Manual by Steven Skiena
(source: alberton.info)
Another C library worth checking out, especially because it hasn't been mentioned in answers to this question and also the other duplicate questions:
the C Algorithms Library, it can be found at http://c-algorithms.sourceforge.net/ and is covered by a BSD-style license, i.e. it can be freely used in any project. I've used it myself in several smaller programs without encountering any problems.
Art of Computer Programming, Volume 1: Fundamental Algorithms (3rd Edition)
http://en.wikipedia.org/wiki/The_Art_of_Computer_Programming

C Pointers - Good Tutorials [duplicate]

This question already has answers here:
Closed 13 years ago.
Possible Duplicate:
What are the barriers to understanding pointers and what can be done to overcome them?
Was just wondering if anyone could "point me" to a good tutorial on pointers
Would be very greatful
Thanks
The best start is Kernighan and Ritchie book of "Programming in C".
There is always Pointer Fun with Binky, produced by Stanford.
Well, http://pweb.netcom.com/~tjensen/ptr/cpoint.htm seems quite reasonable.
I like C for smarties a lot. It deals with many of the issues people face with pointers, is written by someone who knows C very well, and to paraphrase Einstein, doesn't simplify things more than they need to be. In particular, you should read "Are pointers numbers?", and "More on arrays and pointers" from the website.
Also, see comp.lang.c FAQ, sections 4, 5, 6, and 7.
While not related only to pointers, Defensive Programming is something that should definitely read up on and practice.It greatly reduces the number of mistakes that a programmer can mak
Here's a couple of nice links:
Dr Dobbs - http://www.drdobbs.com/cpp/184401915
Defensive C Programming - http://geofftop.com/Defensive_C_Programming.html
Read The C Programming Language by Brian Kernighan and Dennis Ritchie; it is excellent.

Resources