All Questions
10,934
questions
2
votes
3
answers
112
views
Converting to char*** from char* [2][2]
I have the following variable
char* a[2][2] = {{"123", "456"}, {"234", "567"}};
I wanted to refer it using another variable. While the cast works, accessing ...
1
vote
3
answers
75
views
In C, why can a variable holding a char array be assigned to a pointer, but the address of the same pointer cannot?
Consider the following code:
char stringy[] = "There's too much confusion, I can't get no relief!";
char *pStringy;
pStringy = stringy;
This compiles -
stringy is an array of characters, ...
0
votes
2
answers
61
views
Is the & operator is essential to use as address operator [duplicate]
#include<stdio.h>
int main()
{
int a[5]={5,10,15,20,25};
int *p;
int i;
p=a;
for (i=0;i<=5;i++)
{
printf("the address of the %d is = %d\n",*p,p);
...
1
vote
1
answer
105
views
Arrays, Pointers and Memory addresses instances confusion in C++
I'm learning and playing a bit with pointers and memory addresses.
The thing is that I've tried doing some moves with instances inside arrays and getting their memory address, and I can't figure out ...
-3
votes
1
answer
83
views
Why does incrementing a pointer to an array give this result?
If I define a new (int) array, and increment the dereferenced pointer to this array by 1, why do I get the following result?
int main()
{
int myArray[1024];
myArray[0] = 123;
myArray[...
2
votes
3
answers
103
views
Do brackets have effect during array of pointers declaration?
Recently I was reading "The C programming language" text book by Brain and Dennis and encountered that there is a difference between the pointer array definitions shown below:
int (*a)[10];
...
-2
votes
0
answers
32
views
Getting array items with + operator [duplicate]
As far as I know, array variables are pointers to the first item of array, so for me to access them without a[1], and with + operator, I should increase pointer address by 1 to get second item of the ...
0
votes
1
answer
35
views
How to know heap overflow point?
I'm attempting to write a program that determines all palindrome within a given range. My program calls a function (number of digits) that returns the size of an integer (ie. 400 would be 3 as it has ...
4
votes
1
answer
71
views
typedef for constant pointer to constant data function array
I have a C header file (.h):
typedef uint8_t paraFunction(uint8_t paraVal, uint8_t paraNum);
paraFunction *paraCallTable[256];
And I have a C source file (.c):
paraFunction *paraCallTable[] = { fn1,...
0
votes
0
answers
51
views
Allocated memory in heap by a function() is acting like stack memory [duplicate]
I have been searching for 2 days , I read similar posts but still can`t grasp what is
happening in my heap memory.
I want to make a program that takes a password from cmd arguments of the program ...
0
votes
0
answers
41
views
Fortran pointers and allocated arrays, what happens after a "deallocate"? [duplicate]
The following little code compiles and runs w/o error, and gives expected results:
$ cat ptrpractice.F90
program ptrpractice
integer, allocatable, target :: c(:)
integer, pointer :: d(:)
allocate(c(...
1
vote
1
answer
62
views
Memory locations in Fortran: sometimes yes, sometimes no
I would like to know the reason for the difference in output between just_checking_1 and just_checking_2 in the below toy code. I guess this boils down to what is the difference between a(*) and a(:)....
1
vote
2
answers
262
views
How to dereference an object pointer?
Currently I have a student class and a roster class. The roster class is holding an array of pointers that point towards objects of the student class.
student* RosterArray[20];
cR.RosterArray[0] = &...
0
votes
2
answers
79
views
Jagged Array in C without Dynamic Memory Allocation
Task: Implement a function in standard C that constructs a jagged array J from a linear array W. You must adhere to the following specifications and constraints:
Input: The function takes a ...
0
votes
1
answer
86
views
why cant i access the location in char pointer array with dereference to int pointer as index
im making a project and i was getting an error out of nowhere supposedly so i went into debug mode and couldn't find the error but the error only occurred in a specific place so i copied the code and ...