Palindrome Program Gone Wrong- Please Help

I've been taking this online Stanford class for a while now and the assignments are starting to not make sense. I'm looking for help fixing this mess of a code. The program is supposed to read a string, and tell the user if that string is a palindrome. I'm getting such errors as "shadows a parameter" that I don't understand how to fix. If you have time to help, please do. Thanks, Mike.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <stdio.h>
#include "genlib.h"
#include "simpio.h"
#include <iostream>
#include <string>

/* File name: PalindromeFinder.c
* This program finds palindromes
*         */

using namespace std;

void GetString(int s[]);
void Check(int s[]);

int main()
{
  int s[100],first,last,flag=1; 
  char str[100]; 
   
    GetString(s);
    Check(s);
 
}  

void GetString(int s[])
{
    int s[100];
    char str;
    printf("Please enter the word to be checked:  ");
    str=getchar();
}

void Check(int s[])
{
    first=0; 
    last=strlen(str)-1; 


    printf("%d",first); 
    printf("%d",last); 

    while(first<=last) 
     { 
       if(str[first]!=str[last]) 
       flag=0; 
       first++; 
       last--; 
      } 
    if(flag==1) 
     {  
      printf("this is palindrome"); 
      getch(); 
     } 
    else 
     { 
      printf("sorry this is not a palindrome"); 
      getch(); 
     } 
}
a) You are using str, which arent declared anywhere in your check function.
b) In GetString you... getting char which is destroed immideatly?
b) "parameter shadowing" is when you declaring variable which has the same name as another, so that variable becoes inaccessible: in GetString function you cannot access s[] argument because of s[100] local variable
Topic archived. No new replies allowed.