2D Array Basics | C Programming Tutorial

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Hey Mate, You are the best! Love and respect to You, dear professor, from a regular ukrainian C fan. I wish I could be Your student at the university 😌

noskov
Автор

actually this is my field of work "Matrix", I work with finite elements analysis and I will implemented it this week in one of my Home Work. Thank you for your help

naboulsikhalid
Автор

thank you so much for your tutorials <3

gormarduck
Автор

Please how can I replace an int array with a different int array?

theintelmedia
Автор

I have a question, if I have a 2d array how can I make it so that the first line and first row are all filled with the number 0? (basically I want any 'coordenate' with x or y = 0 to have the numeric value 0). This is the code I have for generating the matrix:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_LIMIT  1000
int main (){

    int l, c;
    int i, j;
    int m, n;
    char str[MAX_LIMIT];
    int sum;
    int zero = 0;

    scanf(" %d %d", &l, &c); // scan number of lines and columns
    fflush(stdin);
   
    int **mat = (int **)malloc((l+1) * sizeof(int*));
    if (**mat == NULL)
        return;
    for(i = 0; i < l+1; i++) mat[i] = (int *)malloc((c+1) * sizeof(int));
   
    for(i=1; i<=l; i++){ // get elements of 2d array (insert numbers line by line with space)
        j=1;
        fgets(str, MAX_LIMIT, stdin);
        char *token = strtok(str, " ");
        while (token != NULL)
        {
            mat[i][j]= atoi(token);
            j++;
            token = strtok(NULL, " ");
            printf("")
        }            
    }

rafacastellano
Автор

How to take input in 2d char array in c ?

yogeshchauhan
Автор

Amazing, please do that with a function 🙏

ettajunior
Автор

love the vids, was wondering can you make a video about an array of lists, (an array and each block of the array points at a list, and how to move through it ) thanks

hasan-hrkl