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

Multiple WHILE loops help
Hi there. I'm writing an application that is pulling and displaying results for real estate listing

Backflush
I am looking for a report in SAP that would give me a list of all parts that are populated with a ba

how can we add data from dynamic fields to mysql db in php
i have a script which i found on the internet. i modify that script according to my needs. what is i

couldn't connect to your database
Hello I am new to php mysql

Actually i have read A tutorial on nettuts
"http://net.tu

mysql select query problem
how can i select multiple fields from multiple table in one query like

i have table name t1 a

Problems with returning true or false in eval()'d code
Hi guys,

Would appreciate some help with a problem when running eval() on a function that sho

PECL uploadprogress for php5.2
Hey, I just installed PHP5 via .htaccess on my 1and1 Shared Hosting Account.

How would I exac

Time script, set to my time zone?
I am using this line to get the date and time

Code: $time = date(F." ".d.", &q

problem with php mysql query
Hi guy's...

I'm totally lost here..because don't have any idea how to make a query for grab r

filesize() returns 0
I have a socket program that runs in an infinite loop, listening for connections, in this socket I h

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