c pointers, Anyone got fundamental issues? [duplicate] - c

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.

Related

difficulty in understanding how pointers work in c [duplicate]

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

Datatype which can store very large value in C [duplicate]

This question already has answers here:
Are there any solid large integer implementations in C? [closed]
(7 answers)
Closed 8 years ago.
Recently in programming contest in Here, the problem is pretty straight forward but catch is with worst case scenario which we have to handle data of size 10^10000 .
I tried the program in python which is straight forward as i don't have to specify the datatype(It is taken care by the compiler ) but when i tried with C I couldn't find the correct datatype .
(I tried uintmax_t which didn't work out too).
So how to approach very huge type of data's in C ?
There is no built-in datatype in C that can store that big values. You will either have to write your own implementation or use a library. As this is a competition, though the second is not an option. Every now and then similar problems appear and usually the best approach is to use another language e.g. java(as it is usually available on competitions).

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.

Concept of function pointers in C? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
What is the point of function pointers?
hi all,
I want to get the basic and concrete idea of function pointers in C language.
ie 1) its usage in C
2) main applications it is currently using
3) unique features
4) its scope in embedded applciations etc
Hoping your co operation in this too.
__Kanu
Function Pointers are pointers, that is variables, which point to the address of a function.
Nice example here. Also this answer is a must read.

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