指针、字符串

#include<stdio.h>
int strcmp(const char *s1, const char *s2)
{
  int i = 0;
  while ('
#include<stdio.h>
int strcmp(const char *s1, const char *s2)
{
int i = 0;
while ('\0' != s1[i] && '\0' != s2[i])
{
if (s1[i] > s2[i])
return 1;
else if (s1[i] < s2[i])
return 2;
else
i++;	
}
return 0;
}
int main(void)
{
char ch1[] = "abcdef";
char ch2[] = "abcedf";
printf("%d", strcmp(ch1, ch2));
return 0;
}
' != s1[i] && '
#include<stdio.h>
int strcmp(const char *s1, const char *s2)
{
int i = 0;
while ('\0' != s1[i] && '\0' != s2[i])
{
if (s1[i] > s2[i])
return 1;
else if (s1[i] < s2[i])
return 2;
else
i++;	
}
return 0;
}
int main(void)
{
char ch1[] = "abcdef";
char ch2[] = "abcedf";
printf("%d", strcmp(ch1, ch2));
return 0;
}
' != s2[i]) { if (s1[i] > s2[i]) return 1; else if (s1[i] < s2[i]) return 2; else i++; } return 0; } int main(void) { char ch1[] = "abcdef"; char ch2[] = "abcedf"; printf("%d", strcmp(ch1, ch2)); return 0; }

 

说点什么

avatar

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

  Subscribe  
提醒