problem in program for counting no of chars using pointers


Posted on 16th Feb 2014 07:03 pm by admin

Hi all, I was trying to make a program which counts number of chars in a string using concpt of pointers. Following is the code:

#include
#include
void main()
{
char *ptr1;
int ctr=0;
clrscr();

printf("Enter the string");
gets(ptr1);
while(1)
{

if(*ptr1!='/O')

{ *++ptr1; // *ptr1++;
ctr++;}
if(*ptr1 ='')
{
break;}
}
printf("Total chars are %d",ctr+1);
getch();
}

Above program compiles w/o errors but gives 2 warnings :
Line 14: Constant out of range in comparison.
Line 18: Possibly incorrect assignment.

I think I code it perfectly and I fail to interpret these warnings.
Note: If I execute the program ignoring the warning then once I pass the string the system comes to an halt and to come out I have to press ctrl+Pause break.
Pls help me to fix the error.....

Thanks

No comments posted yet

Your Answer:

Login to answer
229 Like 34 Dislike
Previous forums Next forums
Other forums

While Problem
i am having a problem with a while statement here is the code
Code: [Select]<?php
sess

PHP - HTTP Digest Authentication - Understanding Code Help
Hi Everyone,

This is my first time on your website and please excuse if I am asking silly que

php mysql script to find record
Hi,

Currently I have a simple table with 4 columns. A, B, C, D

If I want to find all

Error when call dll from oracle
Hi all, please help me!

I have dll write C language, I want call it from oracle procedur

help with Get_
ok some how this is not working i am not sure what i am doing wrong here but what this does is when

RSS feed - FeedList for WordPress
Hi,

I'm trying to alter the FeedList plugin for WordPress so that I can click on the title of

PHP doesn't send my mail
Hi all, I found this and used it to send mail. Simple contact form with some required fields. The va

PHP & Images [Resize, Crop, Save]
Hey! Well I have a little dilema, hoping I could find some guidance.

I have a CMS and on the

Upload file!
Ok i have a form..
Code: <form name="form1" method="post" action=&quo

VAT
how should I deal with VAT?

if I have a product that costs £5.00 and VAT @ 17.5% (£0.87

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash