473,786 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mr program is compiling but not running correctly ... please help

2 New Member
#include <stdio.h>
#include <string.h>
#define SIZE 80

int main ()
{

char word[SIZE];
int i;
int length =0;
int palindrome ;


printf("Please enter a word\n");
//printf("termina ted by -1\n");
//do
// {
scanf("%s", word);
i++;
//}
//while

(word[i-1] != -1 && i < SIZE);
// length = i -1;

for (i=0; i < length/2 && palindrome == 1 ;i++)
{
if (word[i] != word[length - i - 1]) /*test if not the same */
palindrome = 0;
}


if (palindrome == 1)
printf("array is a palindrome\n");
else
printf("array is not a palindrome\n");
return 0;
}
Oct 31 '06 #1
3 1579
Banfa
9,065 Recognized Expert Moderator Expert
What is it supposed to do?

What does it actually do?
Nov 1 '06 #2
JILIAN
2 New Member
What is it supposed to do?

What does it actually do?

IT is supposd to find out if a word is a palindrome or not
Nov 1 '06 #3
horace1
1,510 Recognized Expert Top Contributor
before the for() statement you need to initialse the variables
length=strlen(w ord);
palindrome=1 ;
Nov 1 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3005
by: Will Stuyvesant | last post by:
I never used the popen or popen2 libraries but it is my understanding that they can capture the output of console based programs. Is it also possible to send keystrokes to console base programs? I would like to program a Python program that can play for instance the tty version of nethack 3.4.3 on Windows, simulating a human player: for nethack it would not be possible to know if a human or a computer program is playing it. It is a...
27
3284
by: hpy_awad | last post by:
I wrote that program from a book that my compile that program correctly under C++ compiler but I got those errors for compiling under unix !! Errors- -------- part10_iti_r01_ch10_verbo_menu_driven_programs.c: In function `main': part10_iti_r01_ch10_verbo_menu_driven_programs.c:6: warning: declaration of `argc' shadows a parameter part10_iti_r01_ch10_verbo_menu_driven_programs.c:7: warning:
4
1488
by: Denise Mills | last post by:
Hi, On my previous Windows 98 machine, I wrote a simple C program that takes two text files as input, performs some calculations, then produces a text file that contains the results. It worked fine on that machine. Recently, however, I obtained a new Windows XP machine, and the program is not working correctly on my new computer computer. On the new XP machine, I'm running the program in the DOS window, as before, and the program does...
20
2623
by: Francine.Neary | last post by:
I am learning C, having fun with strings & pointers at the moment! The following program is my solution to an exercise to take an input, strip the first word, and output the rest. It works fine when you give it 2 or more words, but when there's only 1 word the results vary depending on whether it's on Windows or Linux: under MSVC it displays no output (as it should); under gcc/Linux it instead gives "Segmentation fault". Any ideas...
5
6077
by: rasmidas | last post by:
I have written a file as below: #include<stdio.h> #include<string.h> #include<stdlib.h> int main() { char* items; int i; for(i=0;i<2;i++)
62
3170
by: Ajinkya | last post by:
As "spawnl" executes an exe through C code., similarly how can we compile a C program through another C program (on Windows platform) ?
3
1721
by: Nanoooo | last post by:
hello, I have to do the program for the bounded buffer problem in UNIX C and what I have so far is the following code #include"genSema.h" #include<stdlib.h> #include<stdio.h> #include<pthread.h> #include<sys/types.h> #include<sys/times.h>
2
1954
by: kwai | last post by:
Hi everyone . I have a XP Sr3 PC and and running Dev C++ .My program is compiling with no errors but gives an windows error when run.Program has encountered a problem and will be closed etc. The Dev program folder also disappears from the c drive so i have to be constantly reinstalling Dev . What could be causing this. Virus? I am running Mc afee and it's current. HELP Please :-). I have exam to study for.
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8992
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.