简体   繁体   English

将常数char放入char矩阵

[英]Putting a constant char in a char matrix

I have a char matrix (relation[][]) and I want to put some character in several items of that. 我有一个字符矩阵(relation [] []),我想在其中的几个字符中加上一些字符。 look: 看:

char relation[num_obj][num_obj];
for(k1=0; k1<num_obj; ++k1)
  for(k2=0; k2<num_obj; ++k2)
   if(k1 != k2)
    if(Top[i][j]==1)
     {     
      strstr((const char *)relation[i][j], "T");
      strstr((const char *)relation[i][j], "B");
      }

k1,k2,num_obj are some defined variable. k1,k2,num_obj是一些已定义的变量。 As you see I am trying to put some constant char (like " T, B) to some elements of matrix, but I receive this warning: 如您所见,我正在尝试将一些常量char(例如“ T,B”)放入矩阵的某些元素,但是收到以下警告:

warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]          

Can any one help me in removing this warning. 谁能帮助我删除此警告。 Thanks in advance and all the best :) 预先感谢,并祝一切顺利:)

If you're just trying to write a 'T' into the array, that's just assignment: 如果您只是想在阵列中写入'T' ,那只是分配:

relation[i][j] = 'T';

strstr is a method to find a substring in a string. strstr是在字符串中查找子字符串的方法。 It's only useful for its return-value, so even if you got your code to compile, it just wouldn't do anything. 它仅对返回值有用,因此即使您可以编译代码,它也不会做任何事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM