#include<iostream.h>
using namespace std;

class first
{
int reverse()
{
char name[]={'k','a','v','i','t','h','a','/0'};

int 1=0;

while(name[i] != '/0')
{

i++;

cout<<"value of i is"<<i<<endl;
}
}

int  main()
{
first f;
f.reverse();
}
};

my file's name is cpp.cpp and i cannot run it using ./a.out

I get a warnings as follows:

1. multi-character character constant
2. comparison is always true due to the limited range of the data type

error:


1. in member function 'int first::reverse()':


2. undefined symbols

"_main", referenced from:

start in crt1.10.5.o
id: symbol (s) not found
collect2: Id returned 1 exit status

Can you please help me figure out as to what problem this is ?

#include<iostream.h>
using namespace std;

class first
{
int reverse()
{
char name[]={'k','a','v','i','t','h','a','/0'};

int 1=0;

while(name[i] != '/0')
{

i++;

cout<<"value of i is"<<i<<endl;
}
}

int  main()
{
first f;
f.reverse();
}
};

my file's name is cpp.cpp and i cannot run it using ./a.out

I get a warnings as follows:

1. multi-character character constant
2. comparison is always true due to the limited range of the data type

error:


1. in member function 'int first::reverse()':


2. undefined symbols

"_main", referenced from:

start in crt1.10.5.o
id: symbol (s) not found
collect2: Id returned 1 exit status

Can you please help me figure out as to what problem this is ?

Should be something like this::

#include<iostream>//Watch out
using namespace std;

class first
{
 public:   //Added
int reverse()
 {
char name[]={'k','a','v','i','t','h','a','\0'};//Salem's comment

int i=0; //Should be i

  while(name[i] != '\0')
 {
  i++;
  cout<<"value of i is"<<i<<endl;
  }
 }
};  //Watch this
int  main()
{
 first f;
 f.reverse();
 cin.get();//Added
 return 0;   //Added
}

zalezog please don't add cin.get() to the end of people code snippets, they are not wrong by not using it. I would be more inclined to say you are wrong in using it.

Chris

Comments
I really hate trailing get/pause etc.
This article has been dead for over six months. Start a new discussion instead.