470,632 Members | 1,333 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,632 developers. It's quick & easy.

ambiguates old declaration

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <string.h>
  4. void strrev (char *string)
  5. {
  6.         int len=strlen(string);
  7.         char string2[20];
  8.         for(int i=0; i<len; i++){
  9.                 string2[i]=string[len-1-i];
  10.                 }
  12.      }
  14. int main(){
  15.     char string[20]="Program";
  16.     strrev(string);
  18.     return 0;
  19.     }
I am trying to write a simple code to reverse a character string. But at line 5 i am getting the following error:
new declaration `void strrev(char*)'

What is my mistake. And how can I port the reversed word from void into main?

Thank you for your answers
Jun 13 '15 #1
1 7689
9,208 Expert Mod 8TB
You have inadvertently used the name strrev for your function and this is also the same name as the C library function strrev.

In C function names must be unique.

You have to change the name of your function.
Jun 13 '15 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

83 posts views Thread by Alexander Zatvornitskiy | last post: by
10 posts views Thread by Christopher Benson-Manica | last post: by
8 posts views Thread by newmans | last post: by
10 posts views Thread by Kobu | last post: by
25 posts views Thread by venky | last post: by
2 posts views Thread by Alan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.