Hi -
Here is the corrected version:
Code:
#include <stdio.h>
void display (char []);
int main()
{
char message[] = "Vacation is near";
display (message);
return 0;
}
void display (char*strng)
{
while (*strng)
{
printf("%c", *strng);
strng++;
}
printf("\n");
}
Here were the problems:
1. You can't increment a literal constant like "0"
<= THIS WAS THE PROBLEM THAT CAUSED THE
TWO COMPILER ERRORS
2. You didn't need an array index, you could just increment the
pointer variable directly (this is the approach I took above).
Here's the same code using an index:
Code:
void display (char*strng)
{
int i = 0;
while (strng[i])
{
printf("%c", strng[i]);
i++;
}
printf("\n");
}
3. Finally, when posting code on LinuxQuestions.org, be sure to take advantage of the different vbCode tags that are available to you: bold, italic, http ... and, in this case, the "code" tag.
Hope that helps .. PSM
(PS: You'll notice that I *didn't* take advantage of the "list" tag. Or the "italic" tag, either ;-)