top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

C compilation error: expected expression before 'char'

+3 votes
2,851 views

I am newbie to C and getting the compilation error in the following function.

int get_names(int students, char names[students][20])
{
        int i;
        for (i = 0; i < students; ++i)
        {
                printf("Enter name for Student %d: ", i);
                scanf("%s", names[i]);
        }
        return char names[students];
}

Error:

return char names[students];
error: expected expression before 'char'
posted Sep 22, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Return statement does not require type name

Wrong

return char names[students];

Right Way

return names[students]; // No char
answer Sep 22, 2015 by Salil Agrawal
Similar Questions
0 votes

Recently I was dealing with some problems in Compiler design. What I want is a tool which can do step by step compilation of the C Program. One which performs lexical analysis and gives an output file and then syntax analysis on this output file and so on until the final executable code is obtained. Is there such a tool or technique to do this?

+1 vote

What type of conversion is not accepted in C and why?
a) char to int
b) float to char pointer
c) int to char
d) double to char

...