如何比较C中的字符串值(strcmp) [英] how to compare string value in C (strcmp)
问题描述
能帮助我吗...我无法解决这个问题。我有一个数组AttValName [Att] [v],它有以下值,
Att = Outlook,
AttValName [Att] [1] = sunny
AttValName [Att] [2] = Rain
AttValName [Att] [3] =阴天
和数据类似,
1.sunny,热,温和,玩
2.晴天,正常,高,不玩耍
3 ....
4 ...
当AttValName [Att] [v] =sunny时,我需要获得记录号码
有可能吗?如果有,你能告诉我怎么样吗?
谢谢。
Hi,
Can you please help me...I am not able solve this issue. I have a array AttValName[Att][v] which has following values,
Att=Outlook,
AttValName[Att][1]=sunny
AttValName[Att][2]=Rain
AttValName[Att][3]=overcast
and data is like,
1.sunny,hot,mild,play
2. sunny,normal,high,Don''y play
3....
4...
and I need to get record number when AttValName[Att][v] = "sunny"
Is is possible to do that? If yes, Can you please tell me how?
Thanks.
推荐答案
使用strcmp()函数比较C字符串。检查您的文档集。
根据您的代码段,您可能还有其他问题。请告诉我们您的进展情况。
Use the strcmp() function to compare C strings. Check your docset.
You may have other problems based on your code snippet. Keep us advised how you are progressing.
我知道我必须使用strcmp()但是,如何从文件中检索每条记录..
here在???的地方如何从文件中获取我的字符串及其记录中没有???
in C.
strcmp(AttValName [Att] [v]," ; ????)
1.晴天,高,低,玩耍
谢谢,
I understand I have to use strcmp() but, how do I retrive each record from the file ..
here at the place of ??? how do I get my string from the file and its record no???
in C.
strcmp(AttValName[Att][v]," ???")
1. sunny, high,low, play
thanks,
使用strcmp()函数比较C字符串。检查您的文档集。
根据您的代码段,您可能还有其他问题。请告诉我们您的进展情况。
Use the strcmp() function to compare C strings. Check your docset.
You may have other problems based on your code snippet. Keep us advised how you are progressing.
您必须将光盘文件读入数组。您显示的数据如下:
晴天,高,低,玩
您可以将此数据读入您分配的缓冲区。缓冲区将包含来自一条记录的数据。也许:
You will have to read the disc file into arrays. You show data like:
sunny, high,low, play
You can read this data into a buffer you allocate. The buffer would contain the data from one record. Maybe:
这篇关于如何比较C中的字符串值(strcmp)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!