#include <stdio.h>
#include <string.h>void main()
{
char str[100], *pStr, *EndStr;
unsigned int count=0; while (1)
{
pStr = gets(str);
if ( strlen(pStr) == 0 )
break;
else
if (strlen(pStr) > count)
{
count = strlen(pStr);
EndStr = pStr;
}
}
printf("%s\n", EndStr);
}为什么结果没是空的呢??请高手指点!
#include <string.h>void main()
{
char str[100], *pStr, *EndStr;
unsigned int count=0; while (1)
{
pStr = gets(str);
if ( strlen(pStr) == 0 )
break;
else
if (strlen(pStr) > count)
{
count = strlen(pStr);
EndStr = pStr;
}
}
printf("%s\n", EndStr);
}为什么结果没是空的呢??请高手指点!
#include <stdio.h>
#include <string.h>
void main()
{
char str[100], *pStr, *EndStr;
unsigned int count=0; while (1)
{
pStr = gets(str);
if ( strlen(pStr) == 0 )
break;
else
if (strlen(pStr) > count)
{
count = strlen(pStr);
EndStr=new char[count];
strcpy(EndStr,pStr);
}
}
printf("%s\n",EndStr);
}
这样就可以了
#include <string.h>
void main()
{ char str[100], *pStr, *EndStr;
unsigned int count=0; while (1)
{
pStr = gets(str);
EndStr="\n";
if ( strlen(pStr) == 0 )
break;
else
if (strlen(pStr) > count)
{
count = strlen(pStr);
EndStr=new char[count];
strcpy(EndStr,pStr);
}
}
printf("%s\n",EndStr);}
#include <string.h>
void main()
{
char str[100], *pStr, EndStr[1000];
unsigned int count=0; while (1)
{
pStr = gets(str);
if ( strlen(pStr) == 0 )
break;
else
if (strlen(pStr) > count)
{
count = strlen(pStr);
strcpy(EndStr,pStr);
}
}
printf("%s\n",EndStr);
}