Bumpy
why i cant doing Matrix[i][j]?
Vlad
In your case I would advice to access it via [i * M + j]
Bumpy
In your case I would advice to access it via [i * M + j]
thank u! so this is the way to modify 2D matrix on C without using the instance of [][]?
Vlad
It's the way to address any 1d array as 2d one
With 2d arrays on stack it's exactly what compiler does
FBI
please can someone help me with pointers in C..?
Vlad
Because it knows the row length. And that's why placing second size is mandatory
Bumpy
Wow! great!
Vlad
please can someone help me with pointers in C..?
To understand the recursion you must first understand the recursion
Vlad
If you catch my drift
Vlad
am confused pls
If you have a distinct question just ask lmao
Vlad
We won't babysit you
FBI
alright
Igor🇺🇦
please can someone help me with pointers in C..?
You need to be more specific what kind of help you need. There are dozens of good tutorials on the Internet if you just need some general information.
MRT
Where is programming needed to define a pointer to pointer variable **var?
Dmitrii
Some 3rd party libs probably or something beyond your control
Trent
Write a C program that prompts a user to enter an interger, and calculate and display it's factorial.The program should be able to reject any wrong inputs(should reject any input whose factorial cannot be determined)
Trent
Help with the question ☝☝☝
Dmitrii
You know what n! is?
MRT
Does anyone know where is the best blockchain teaching university in eu?
Dmitrii
Does anyone know where is the best blockchain teaching university in eu?
ETH, Oxford, Cambridge to name a few You can get familiar with math there
MRT
ETH, Oxford, Cambridge to name a few You can get familiar with math there
How can I learn blockchain programming without a university?
MRT
Where should I start?
MRT
I do not mean solidity
Dmitrii
Where should I start?
Learn math, it's all about cryptography
MRT
math :-ss
MRT
it's scary
Dmitrii
it's scary
👍👍👍
MRT
But I dream of blockchain and I learn anyway
Dmitrii
But I dream of blockchain and I learn anyway
Just out of curiosity. Have any ideas of what blockchain is?
Anonymous
Where is programming needed to define a pointer to pointer variable **var?
strtod() and some other functions use that convention.
MRT
Just out of curiosity. Have any ideas of what blockchain is?
I would like to build an operating system based blockchain
Vlad
What does it need blockchain for? XD
MRT
An operating system that keeps your performance to itself forever
Vedant
Anonymous
BASED on Tigo Pesa service (*150*01#) Write a C++ program that utilize a switch…….case statement to operate the services. Your program should display the main menu, and then expand a specific case as per the question. NOTE: i. The rest of the cases that does not correspond to your question should be implemented with just a statement that display the name of the service ii. In case user entered a wrong value, should be taken back to the previous menu and given an option to enter another choice/value. iii. You have to assume the fee charged for each service/amount and include them in your program if and only if the service is charged. Q: voucher na packs →Tigo pack →Month + Bonus →Internet→Tsh 20000 GB9
Anonymous
Can I have help on that 😞😞
Anonymous
Dq
Anonymous
AHMED
Anonymous
@everyir98
Bumpy
void buildMatrix(int n , int m) { int Matrix = NULL; Matrix = (int)(calloc(n,sizeof(int))); for (int j = 0; j < n; j++) { Matrix[j] = (int*)(calloc)(m,sizeof(int)); } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { Matrix[i][j] = rand() %10; } } printMatrix(Matrix,n,m); } void printMatrix(int **Matrix, int n , int m) { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { printf("%d ", Matrix[i][j]); } printf("\n"); } for (int j = 0; j < n; j++) { if (Matrix != NULL) { free(Matrix[j]); } } }
Bumpy
why i get an Segmentation fault (core dumped) error
Vlad
ftw
Vlad
Also printMatrix function accepts int**
Vlad
It is not compatible with int*
Bumpy
i dont understand why .
Bumpy
in geeks for geeks its like that
Vlad
in geeks for geeks its like that
Geeks for geeks has some really disgusting code snippets. ngl
Bumpy
i cant send **int as parameter?
Bumpy
oh.. im sorry i didnt saw that :(
Vlad
int Matrix = NULL; Matrix = (int)(calloc(n,sizeof(int))); for (int j = 0; j < n; j++) { Matrix[j] = (int*)(calloc)(m,sizeof(int)); } -> int** Matrix = calloc(n, sizeof(int*)); for (int j = 0; j < n; j++) { Matrix[j] = (int*)(calloc)(m, sizeof(int)); }
Bumpy
if i was using in 32bit it was fine?
Vlad
if i was using in 32bit it was fine?
Never use the sizeof of different type
Vlad
You just hinder portabilty for nothing
Bumpy
👍
Vlad
Also sizeof(*ptr) is a thing. So you'll never mess up
Aakash
in geeks for geeks its like that
Your code looks quite nasty! Can you submit the geeks link;
Anonymous
void buildMatrix(int n , int m) { int Matrix = NULL; Matrix = (int)(calloc(n,sizeof(int))); for (int j = 0; j < n; j++) { Matrix[j] = (int*)(calloc)(m,sizeof(int)); } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { Matrix[i][j] = rand() %10; } } printMatrix(Matrix,n,m); } void printMatrix(int **Matrix, int n , int m) { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { printf("%d ", Matrix[i][j]); } printf("\n"); } for (int j = 0; j < n; j++) { if (Matrix != NULL) { free(Matrix[j]); } } }
typedef struct { int **$; int rows; int cols; int _data[0]; } Matrix; Matrix* new_Matrix(int rows, int cols) { Matrix *mat = calloc(sizeof(Matrix) + rows*cols*sizeof(int)); int **$ = malloc(rows*sizeof(int*)); // size of pointer, not int if(!mat || !$) { free(mat); free($); return NULL; } mat->$ = $; mat->rows = rows; mat->cols = cols; for(int i = 0; i < rows; i++) $[i] = &mat->_data[width*i]; return mat; } void destroy_Matrix(Matrix *mat) { free(mat->$); free(mat); }
Silent
Could anyone suggest an easy learnable book for C data structures ?
Anonymous
Could anyone suggest an easy learnable book for C data structures ?
C and data structures are different topics You either learn one or the other
Anonymous
If you can find an old-fashioned Pascal book at a used bookstore it would translate to C pretty good...
Diego
Could anyone suggest an easy learnable book for C data structures ?
If you're talking about C & C++'s struct they're literally a collection of things
Diego
A structure containing an int and a long is literally each thing individually but you can access them with one variable
eric_maina
hi, guys in c ++ how do I use cin«..; for a user to enter a number which shall not exceed 100, for example when a user is keying in marks for a subject,the programme shall not allow him/her to enter a number greater than 100
Cavidan
Hello
Cavidan
Do you know c++?
Atropos
Do you know c++?
No one knows. C++ just a group name
Cavidan
Write a C program that discards the elements larger than 4 and smaller than 10 in a user-defined matrix of N * M to a separate array and print this new array on the screen.