Home > Back-end >  C language compiler running string output is the result of the white square is what's going on
C language compiler running string output is the result of the white square is what's going on

Time:03-07

CodePudding user response:

Should be a string, not the end of the character '\ 0',
Suggest check whether add don't add after effective string '\ 0',

In addition, also recommends to the code,

CodePudding user response:

Code is wrong so

So ask someone else can answer you

CodePudding user response:

Maybe it's the array of what don't memory allocation is not initialized

CodePudding user response:

This is the code
# include
# define MAXLINE 1000
Int getline (char line [], int maxline);
Void copy (char to [], char from []);
The main ()
{
Int len.
Int Max;
Char line [MAXLINE];
Char longest [MAXLINE];
Max=0;
While ((len=getline (line, MAXLINE)) & gt; 0)
If (len> Max) {
Max=len;
Copy (longest, line);
}
If (max> 0)
Printf (" % s ", the longest);
return 0;
}
Int getline (char [s], int lim)
{
C, int I;
for(i=0; iS [I]=c;
If (c=='\ n') {
S [I]=c;
+ + I;
}
S [I]='\ 0';
return i;
}
Void copy (char to [], char from [])
{
int i;
i=0;
While ((to [I]=the from [I]!='\ 0'))
+ + I;
}

reference 1/f, confident boy reply:
should be a string no terminator '\ 0',
Suggest check whether add don't add after effective string '\ 0',

In addition, also recommends to the code,


refer to the second floor lin5161678 response:
code is wrong so

You so ask someone else can answer


reference 3 floor was raining - xiao response:
probably due to an array of what no allocation is not initialized memory

CodePudding user response:

reference 1/f, confident boy reply:
should be a string no terminator '\ 0',
Suggest check whether add don't add after effective string '\ 0',

In addition, also recommends to the code,


refer to the second floor lin5161678 response:
code is wrong so

You so ask someone else can answer


reference 3 floor was raining - xiao response:
probably due to an array of what no allocation is not initialized memory


I found the problem is the code while ((to [I]=the from [I]! ))='\ 0' wrong number brackets should be while here ((to [I]=the from [I])!='\ 0')
Can you tell me why I dialed the wrong number here in accordance with the assignment operation should be directly over how can appear small box??

CodePudding user response:

reference 5 floor weixin_44417360 reply:
Quote: reference 1/f, confident boy reply:

Should be a string, not the end of the character '\ 0',
Suggest check whether add don't add after effective string '\ 0',

In addition, also recommends to the code,


refer to the second floor lin5161678 response:
code is wrong so

You so ask someone else can answer



reference 3 floor was raining - xiao response:
probably due to an array of what no allocation is not initialized memory


I found the problem is the code while ((to [I]=the from [I]! ))='\ 0' wrong number brackets should be while here ((to [I]=the from [I])!='\ 0')
Can you tell me why I dialed the wrong number here in accordance with the assignment operation should be directly over how can appear small box??

There is no '\ 0' that is the to array, so such problems

CodePudding user response:

The value of 0, 1 assigned to each time to [I]

CodePudding user response:

You and see if it is out of memory
  • Related