WSAStartup(MAKEWORD(2, 1), &wsaData); 为什么 会出错
#pragma comment(lib, "Ws2_32.lib ")
凡是在link里报告error LNK2001: unresolved external symbol __imp__WSAGetLastError@0之类的都是没有导入lib。。或者是只添加了h到工程,而没有把cpp添加到工程中。
比较两个字符串是否相等
int strcmp(const char *a, const char *b)
{
while(*a && *b) {
if(*a++ != *b++) return 1;
}
if(*a || *b) return 1;
return 0;
}
///////////////////////////////////
while(*a && *b) {
if(*a++ != *b++){
cout<<"!Equal...";
return 0;
}
}
if(*a || *b)
cout<<"!Equal...";
else
cout<<"Equal...";
return 0;
strcmp
Syntax:
#include <string.h>
int strcmp( const char *str1, const char *str2 );
The function strcmp() compares str1 and str2, then returns:
Return value Explanation
less than 0 str1 is less than str2
equal to 0 str1 is equal to str2
greater than 0 str1 is greater than str2
For example:
printf( "Enter your name: " );
scanf( "%s", name );
if( strcmp( name, "Mary" ) == 0 )
printf( "Hello, Dr. Mary!\n" );
评论