请教下,怎么查到数组中,某个字符串,在数组中的索引位置?

请教下,怎么查到数组中,某个字符串,在数组中的索引位置? 是不是有这个涵数,函数名是什么啊?谢谢!!!!

strstr在字符串中查找指定字符串的第一次出现char *strstr(char *str1, char *str2);如果想找索引可以将返回的指针减去str1 即是索引。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-06-13
Java的?如果是的话我记得String类有个方法返回该元素的下标,不过我忘记具体是哪个了。。可以写个方法测试:for(int i=0;i<array.length();i++){ if(str[i].equles(foo)){ System.out.print(i); }}foo为待求字符串本人新手,不过希望能帮到你
第2个回答  推荐于2018-03-29
从文件中读取字符串到数组中 02 03 03 01 04 0f 0s 0g 0a 0f
02 03 03 01 04 0f 0s 0g 0a 0f
02 03 03 01 04 0f 0s 0g 0a 0f
02 03 03 01 04 0f 0s 0g 0a 0f
02 03 03 01 04 0f 0s 0g 0a 0f
02 03 03 01 04 0f 0s 0g 0a 0f
02 03 03 01 04 0f 0s 0g 0a 0f
02 03 03 01 04 0f 0s 0g 0a 0f
02 03 03 01 04 0f 0s 0g 0a 0f
02 03 03 01 04 0f 0s 0g 0a 12
文件D:\123.txt中有如上数据(string型)
怎样复制到string数组a[10,10]中
谢谢
C#语言描述.

最佳答案
using System.IO;StreamReader sr = new StreamReader(@"D:\123.txt");
string tempStr = sr.ReadToEnd();
string[][] a = new string[10,10];
//根据,分开
string[] strs = tempStr.Split(new char[] { ' ,' });
int tempIndex =0;
for (int i = 0; i < 10; i++)
{
for (int j= 0;j < 10; j++)
{
a[i][j] = strs[tempIndex];
tempIndex++;
}本回答被网友采纳
第3个回答  2013-06-13
是什么编程语言啊?C还是C#
相似回答