By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,276 Members | 1,951 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,276 IT Pros & Developers. It's quick & easy.

ambiguates old declaration

P: 1
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  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.                 }
  11.  
  12.      }
  13.  
  14. int main(){
  15.     char string[20]="Program";
  16.     strrev(string);
  17.  
  18.     return 0;
  19.     }
  20.  
  21.  
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
Share this Question
Share on Google+
1 Reply


weaknessforcats
Expert Mod 5K+
P: 9,197
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.