and this is the checkpal.c file:
which as you can probably see...i'm very unsure about alot of it.
Code:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "checkpal.h"
int Checkifpal(void){
int r, l;
int strlen1(char buf[]);
int len = 0;
char fwd[len];
for (r=0; r < len; r++){ /* 1st for loop reads from right and increments*/
if ( MAX_LINES == r)
return r;
return (-1);
}
int strlen2(char fwd[]);
int len2 = 0;
char bkward[len2];
char buf[MAX_LINES];
for (l=len2; l > 0; l--) { /* 2nd for loop reads from left and decrements*/
if (MAX_LINES == l)
return l;
return (-1);
}
/*compare from two for loops and print*/
if (fwd == bkward) {
printf("yes/t%s", buf); /*print yes, tab space and then prints the buf string*/
}
else {
printf("no/t%s", buf); /*otherwise if != print no, tabspace, buf string*/
}
return 0;
}
/* Removes non alphanumeric */
int main(void)
{
int pos;
int dest = 0;
char buf[BUFSIZE];
for (pos = 0; buf[pos] != '\0'; pos++)
{
if (isalnum(buf[pos]))
buf[dest++] = buf[pos];
}
buf[dest] = '\0';
/* Convert upper to lower case */
for (pos=0;buf[pos] != '\0'; pos++)
{
if (isupper(buf[pos])!= 0)
buf[pos] = tolower(pos);
else
{
buf[pos] = pos;
}
}
return();
}
/*Convert upper to lower case #2 using while instead of for
int i =0;
char array[BUFSIZE];
while (buf != EOF)
{
if (buf >= 'A' && buf <= 'Z')
buf = tolower(buf);
array[i++] = buf;
}
array[i] = '\0';
puts (array);
return 0;
}
*/
and the header file:
Code:
#ifndef _CHECKPAL_H_
#define _CHECKPAL_H_
#define BUFSIZE 40
#define MAX_LINES 500
int Checkifpal(void);
#endif