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
Did you know?Explore Trending and Topic pages for more stories like this.
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

help with email script...
hey

I need help with my mail script

when the form on http://www.mcgdesignstudio.com/c

str_replace help
I am thinking str_replace is my only option to filter outputs from my database to convert them to sa

Taxonomy? Classification? Categorisation?
Not sure if there is a way around this classification problem
I have a supplier who produces

help with contest script
I would like to code a contest script to my site but i don't know how. Could someone just give me pu

Performance impact of cookies
Hi, I was just wondering what impact there would be in terms of performance if you where to set then

Uploading Filetypes and placing them in seperate folders.
Hello,

first post , and asking for help im afraid. Very new to PHP, was making good progress

Sessions Value Not Saved
Hi,

Im making a login form and im using this code:
Code: if($login=="true"){

Uploading/Downloading files stored in MySQL database
Hey all,

This problem just came up in my website and I'm having a hard time figuring out what

Preg_match unknown modifyer
Hello,

Im trying to write a little script for my forums i need to get the reply from my forum

Page doesn't expand for content
Hi. I've been testing a query I made. It's here http://lapr1.6te.net/inquerito.php
The page doesn

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