Connecting Tech Pros Worldwide Forums | Help | Site Map

need help about it

Newbie
 
Join Date: Jun 2009
Location: Kathmandu, Nepal
Posts: 12
#1: 3 Weeks Ago
Hi, i am trying to write a code which is equivalent to strlen().
#include<conio.h>
#include<stdio.h>
#include<string.h>
#define max 50
void main()
{
char word[max];
int i,count=0;
clrscr();
puts("Enter a word");
gets(word);
for(i=0;word[i]!="\0";i++)
{
count=count+1;

}
printf("%d",count);
getch();
}
it shows the error as follows:
cannot convert char to * char.
help me to fix it.

Needs Regular Fix
 
Join Date: Jul 2008
Posts: 386
#2: 3 Weeks Ago

re: need help about it


"..." (double quotes) is a null-terminated C string, what you need is '\0' or just 0.
Reply