C 字符串矩阵

标签 c

我遇到一个问题:

Given a matrix of size n x m with type of date strings of characters.
Make a program who print the string of maximum lenght from every line of matrix.

我做了一些事情,但是当我尝试执行时它不起作用。 我不知道为什么。有人可以给我一些建议吗?

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char tab[50][255];
    int m, n, i, j;
    printf("\n Dati numarul de linii : ");
    scanf("%d", &m);
    printf("\n Dati numarul de coloane : ");
    scanf("%d", &n);
    for(i=0; i<m; i++)
    {
       for(j=0; j<n; j++)
       {
          printf("\n Elementul [%d][%d] de tip sir de caractere : ", i+1, j+1);
          scanf("%s", tab[50][255]);
       }
    }
    return 0;
}

最佳答案

char tab[50][5][255];
int m, n, i, j;
printf("\n Dati numarul de linii : ");
scanf("%d", &m);
printf("\n Dati numarul de coloane : ");
scanf("%d", &n);
for(i=0; i<m; i++)
{
   for(j=0; j<n; j++)
   {
      printf("\n Elementul [%d][%d] de tip sir de caractere : ", i+1, j+1);
      scanf("%s", tab[i][j]);
   }
}

关于C 字符串矩阵,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21503378/

相关文章:

c - Linux下可以设置本地时间的定时器吗?

c - 指向当前函数的指针

c - C 中 read() 和 fgets() 的区别

c++ - 在 opencv 中重用设备

c - 调用哪个 ioctl 命令

c - c中逐个字符的结构成员

c - 使用二维数组存储多个字符串

c - C解释中的位运算

c - 更改数组中变量的指针

C数组索引