简体   繁体   中英

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. 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. As you see I am trying to put some constant char (like " T, B) to some elements of matrix, but I receive this warning:

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:

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

strstr is a method to find a substring in a string. It's only useful for its return-value, so even if you got your code to compile, it just wouldn't do anything.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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