Thread: Help needed

  1. #1
    Registered User
    Join Date
    Oct 2018
    Posts
    2

    Help needed

    Hello, I am new to these forums(This being my first post). I am a new programmer in C and I just needed some help in the right direction for a current project. I need to be able to test the input on whether or not it is a palindrome, and somehow ignores any blank or symbols, it only takes into account letters. Just in case someone doesn't know a palindrome is a word or phrase that is read the same from beginning to end. Example would be Amore Roma, as if you spelled it backwards it would still be the same. I am assuming this would need to be done with an array of char that some how matches the beginning and end of the line of codes. But I am having a hard time with how to start this. Any help would be greatly appreciated.
    Last edited by CodingforAss; 10-30-2018 at 12:22 PM.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    You need to know how long the string is, then you just check "matching" letters for equality. Since you're ignoring spaces, you can't necessarily just directly compute the index of the "matching" letter as length-i, so you will have to keep track of a left index and a right index and move each of them appropriately.

  3. #3
    Registered User
    Join Date
    Oct 2018
    Posts
    2
    The thing is the string itself can be any length, it needs to be kinda universal. I will post the code I currently wrote for it in a bit and explain my thought process throughout. Thanks so much for the quick reply!

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    I didn't mean that you should take the length as a constant; but any string has a length and you will need to start by figuring out what the length of the particular string you are working with is.

  5. #5
    Registered User
    Join Date
    Dec 2017
    Posts
    1,107
    Or you could ignore spaces as you read the value in (don't store them in the input string). If you really need to be able to store "any length" of string then you'll need dynamic (re)allocation.
    The best argument against democracy is a five minute conversation with the average voter. - Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help needed please.
    By caz0026 in forum C Programming
    Replies: 6
    Last Post: 04-26-2012, 06:33 AM
  2. Help Needed please!!
    By Carl in forum C++ Programming
    Replies: 3
    Last Post: 04-01-2012, 06:08 AM
  3. gcc/g++ help needed
    By bryan in forum C++ Programming
    Replies: 3
    Last Post: 12-09-2003, 08:37 AM
  4. Help Needed
    By tvenki in forum C Programming
    Replies: 2
    Last Post: 08-13-2003, 03:18 AM
  5. Is this needed
    By vasanth in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 06-28-2002, 08:10 AM

Tags for this Thread