2 Replies - 2277 Views - Last Post: 12 November 2012 - 11:41 AM Rate Topic: -----

#1 ajthehitman@gmail.com  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 09-November 12

Call of Nonfunction

Posted 09 November 2012 - 11:38 PM

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include<process.h>
#include<stdio.h>
void main()
{clrscr();
char str[100];
int i,cnt=0;
cout<<"Enter sring:";
gets(str);
for(i=0;str(i)!='\0';i++)
{if(str(i)==' ')
{cnt++;
}
}
cout<<"\nNo of spaces:"<<cnt;
getch();
}



Its showing 2 errors,Both are 'call of nonfunction' errors. Please tell me how to fix this code to work, btw im using turbo c++ 3.0 DOS version 16 bit. I have an exam and getting confused with this code. So please help immediatly. A lot of thanks to anyone who can help me..

Is This A Good Question/Topic? 0
  • +

Replies To: Call of Nonfunction

#2 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1072
  • View blog
  • Posts: 4,532
  • Joined: 09-June 09

Re: Call of Nonfunction

Posted 10 November 2012 - 05:50 PM

Use the bracket operators [] to access an array element.
for(i=0;str(i)!='\0';i++)
{
   if(str(i)==' ')


Was This Post Helpful? 1
  • +
  • -

#3 Anarion  Icon User is offline

  • The Persian Coder
  • member icon

Reputation: 282
  • View blog
  • Posts: 1,456
  • Joined: 16-May 09

Re: Call of Nonfunction

Posted 12 November 2012 - 11:41 AM

This has nothing to do with your errors, but I highly recomment that you use a more updated compiler. Your code, as it is now (aside from the error parts) does not compile in recent compilers.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1