本文介绍了与C编程相关的问题(入门)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
str [j]!=''\ 0''
是什么意思?
以及如何通过比较字符串和打印最终结果来删除重复字符.
如果str1 = A,B,C,D
和str2 = A,C,E,F,B
str[j] != ''\0''
what it means?
and how to remove duplicate character by comparing both string and print final result.
if str1=A,B,C,D
and str2=A,C,E,F,B
推荐答案
str[j] != '\0'
通常在while循环中使用它来检查是否已达到字符串的最后一个字符.如果它是最后一个字符,则循环将终止.
检查此资源:http://www.cprogramming.com/tutorial/c/lesson9.html
我假设您想删除两个字符串共有的字符.您可以这样做:
This is usually used in a while loop to check if the last charecter of the string has been reached. If it is the last char, the loop will terminate.
Check this resource: http://www.cprogramming.com/tutorial/c/lesson9.html
I assume you want to remove characters common to both strings. You could do this:
int i=0, j=0, index=0;
char tmp;
while(str1[i] != '\0')
{
tmp = str[i];
while(str2[j] != '\0')
{
if( tmp != str2[j] )
{
result[pointer] = tmp; // Copy the non common charecter to result array
pointer++; // Increment pointer
}
j++;
}
i++;
}
这篇关于与C编程相关的问题(入门)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!