C language program error prompt

Source: Internet
Author: User
C language program error-General Linux technology-Linux programming and kernel information. The following is a detailed description. [I = s] This post was last edited by cf0532

The program is as follows. in linux, the following error is always prompted during g ++ compilation:
1. the void of row 3 must be preceded by initiator.
2. the read_column_numbers and rearrange functions are not declared in int main () in the main program.

The first question is, what does it mean?
The second question is that the names of the two functions have been declared.

This program can be compiled in windows. is it different in linux?

Thank you!
CODE: # include
# Include
# Include
# Define MAX_COLS 20
# Define MAX_INPUT 1000

Int read_column_numbers (int columns [], int max );
Void rearrange (char * output, char const * input, int n_columns, int const columns []);

Int main (void)
{
Int n_columns;
Int columns [MAX_COLS];
Char input [MAX_INPUT];
Char output [MAX_INPUT];

N_columns = read_column_numbers (columns, MAX_COLS );


While (gets (input )! = NULL)
{
Printf ("Original input: % s \ n", input );
Rearrange (output, input, n_columns, columns );
Printf ("Rearranged line: % s \ n", output );
}

Return EXIT_SUCCESS;
}

Int read_column_numbers (int columns [], int max)
{
Int num = 0;
Int ch;
While (num <max & scanf ("% d", & columns [num]) = 1 & columns [num]> = 0)
Num + = 1;

If (num % 2! = 0)
{
Puts ("Last column number is not supported Red .");
Exit (EXIT_FAILURE );
}
While (ch = getchar ())! = EOF & ch! = '\ N ')
;
Return num;
}

Void rearrange (char * output, char const * input, int n_columns, int const columns [])
{
Int col;
Int output_col;
Int len;
Len = strlen (input );
Output_col = 0;
For (col = 0; col <n_columns; col + = 2)
{
Int nchars = columns [col + 1]-columns [col] + 1;
If (columns [col]> = len | output_col = MAX_INPUT-1)
Break;
If (output_col + nchars> MAX_INPUT-1)
Nchars = MAX_INPUT-output_col-1;
Strncpy (output + output_col, input + columns [col], nchars );
Output_col + = nchars;
}
Output [output_col] = '\ 0 ';
}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.