i have a C programing code on http://ideone.com/VwHSOa. it's going loopy. need help
Did you try it with scanning in an int rather than a string? Putting a string into an int can cause odd things to happen.
No I haven't? I am a bigginer. can u give me a hint
You used a %s, that is a string. But you declared the variable as type int. Change your scan to take in an int. http://www.cplusplus.com/reference/cstdio/scanf/
It would also help to grab the word from the user with gets() instead of a loop. A second issue is your definition: #define lenght 100 later in the code you are using it, text[length], and it has not been defined because of the spelling error.
still giving me headache
It would be useful for you to include the error messages and/or output you are receiving.
Did it still go for a loop, or has it gotten past that part?
Part of your issue is as @e.mccormick pointed out, you need to change your scanf to accept an integer, scanf("%d", &choice);, as it stands now your value is currently uninitialized and thus has the value of whatever is in that memory location. If you were to initialize it you could see that it then takes on the value of the ascii character and not the integer value. A side issue is that you are copying the input into a 100 character long string, then printing the entire string, giving you garbage after the word. You will be better off copying the input from a temp string and trimming it. You also have your switch statement inside a for loop, this causes the case to be evaluated for every letter of the input word, not sure why you would want this behavior. http://ideone.com/sKuRLN You will need to go through the logic that counts letter occurrence and palindrome validation as they do not currently function, however, the code now completes a process.
Join our real-time social learning platform and learn together with your friends!