This is my code:

#include<stdio.h>
#include<iostream>
#include<string>
#include<conio.h>
#include<fstream>

using namespace std;

class TESTnonteaching
{
private:
		string oname[3];
		string osir_name[3];
		int oid[3];
		
public:
	int count3;
		void TESTadd();
		void TESTsearching();
		//void editing();
		//void TESTdisplay3();
		void TESTsetcount3()
		{	count3=0 ;
		}
};

//ADDING STAFF//

void TESTnonteaching::TESTadd()
{
if(count3>=3)
{cout<<"NO SPACE LEFT"; return;
}
 cout<<"ENTER YOUR NAME \n";
 cout<<"Terminate with '$' "<<endl;
 getline(cin,oname,'$');
 //IF THE USER PRESSES AN INTEGER
 /*if( oname == int intValue ) 
 goto k3;
 k3:
 string IntToString(int intValue) { 
  char *myBuff; 
  string strValue; 
  // Create a new char array 
  myBuff = new char[100]; 
  // Set it to empty 
  memset(myBuff,'\0',100); 
/............................................................/  
//*memset (void *source, int value, size_t num);.
//Know that source is a pointer to the block of memory to fill and value is 
//the character to be set. This byte value is internally converted to an unsigned char. //Num is the number of be set. Memset will set the first num bytes of the memory pointed to by source to the specified value and return source.
//Understand that the C++ memset function is kept in the cstring library.
// You may need to include the string.h header file to use this function.
/................................................................/


 Convert to string 
  itoa(intValue,myBuff,10); 
  //Copy the buffer into the string object 
  strRetVal = myBuff; 
   // Delete the buffer:- 
    delete[] myBuff; 

  return(strValue); 
}
*/
 cout<<"ENTER YOUR SIR NAME \n";
 getline(cin,osir_name,'$');

//IF THE USER ENTERS A NON-ALPHABETICAL VALUE
if( osir_name == int intValue ) 
 goto k3;

G1:
 cout<<"ENTER YOUR ID NUMBER\n";
 cin>>oid[count3];
 /* {
    char TESTarray[3]="";
    cin >> TESTarray;

    for (int index = 0; index < 256 ; ++index)
    {
        if (TESTarray[index] == '\0')//test for end of null terminated string
            break; 
        if (isalpha(TESTarray[index]))
        {
            cout<<"No alphabets allowed.\n\n";
            cin.get();
            exit(0);
        }
    }
    
    if (atoi(TESTarray) > 1000000)
    {
        cout<<"Please do not enter numbers larger than 1,000,000.  \n\n";
        cin.get();
        exit(0);

    }
    
    cout << "Number is OK";

}*/
{
 if(oid[count3]= %||^||*||$||#||@||!||(ch>='A'&&ch<='Z')||(ch>='a'&&ch<='z')||~\\`||;||;||'||"||,||<||>||.||/||?) 
cout<<"ERROR! YOU JUST TYPED A NON-INTEGER VALUE."<<endl;
cout<<"ENTER AN INTEGER PLEASE!"<<endl;
}//pre-if
 for(int i=0;i<count3;i++)
 { if(oid[count3]==oid[i])
    cout<<"ID NUMBER ALREADY EXISTS.";
     goto G1;
 }
++count3;
}

I have to do two things:
1) Check if the user enters anything else except a name in:

cout<<"ENTER YOUR NAME \n";
 cout<<"Terminate with '$' "<<endl;
 getline(cin,oname,'$');

I had this strategy:

{
 if(! ((oname>='A'&&oname<='Z')||(oname>='a'&&oname<='z')) )
 {cout<<"Enter a name please.Alphabets allowed only"<<endl;}
 }

The problem is I cant compare a string with a character,rite? But if not character,then what to compare with a string in order to check that the user is entering a name or anything else.

2) I have to check if the user enters anything else except an integer in:

{
 if(oid[count3]= %||^||*||$||#||@||!||(ch>='A'&&ch<='Z')||(ch>='a'&&ch<='z')||~\\`||;||;||'||"||,||<||>||.||/||?) 
cout<<"ERROR! YOU JUST TYPED A NON-INTEGER VALUE."<<endl;
cout<<"ENTER AN INTEGER PLEASE!"<<endl;
}//p

The problem here is that I cant compare an int array with these symbols :S
How can i compare the integer with them; and how can i check if the user enters a name/character in place of integer?

Kindly help me out with this.
Thanks.

You're on to the right idea. You can use the if statements that you already have (with some modifications) or you can use the functions found in <cctype> (isalpha(), etc.)

Looking at your second to last blue code block, you can see that you can't compare a character to a string, but you can loop through the characters of the string (using a for loop) and check each character.

For your last code box, you need to indicate that the elements you are comparing against are characters. You also can't just chain along your || statements unless you do:

if(oid[count3] == '%' || oid[count3] =='^'|| oid[count3] == '*')  etc.

of course you could put oid[count3] into a temporary character and compare against that to save you typing.

@ Looking at your second to last blue code block, you can see that you can't compare a character to a string, but you can loop through the characters of the string (using a for loop) and check each character.

I need help with it.I didnt catch you.

Characters in a string can be accessed by array notation:

std::string str = "apple";
std::cout<<str[0]<<std::endl;   //a
std::cout<<str[1]<<std::endl;   //p

So go through your string with a for loop, do your testing of each character with your if statement. If they are all alphabet characters, then don't reprompt the user, but if even one of them isn't, go back through and reporompt them:

bool allalpha;
while(!allalpha)
{
   for (over the characters)
   {
       if(character is among 'a' to 'z' or 'A' to 'Z')
            allalpha = true;
       else
       {    allalpha = false;
            break; //out of the for loop  
       }
   }
}

I have one more problem :(
THIS IS LINE 88:-

{//first if loop
int temp;
oid[count3]=temp;
      if(( temp== '%')||temp=='^'||temp=='*'||temp=='$'||temp=='#'||temp=='@'||temp=='!'||temp=='~'||temp'`'||temp==';'||temp==','||temp=='<'||temp=='>'||temp=='.'||temp=='/'||temp=='?'))
;            cout<<"ERROR! YOU JUST TYPED A NON-INTEGER VALUE."<<endl;
            cout<<"ENTER AN INTEGER PLEASE!"<<endl;
 }//first if closing

I cant locate it :(

its giving these errors:

.cpp(88) : error C2143: syntax error : missing ')' before 'constant'
.cpp(88) : error C2059: syntax error : ')'
g.cpp(88) : error C2059: syntax error : ')'

You've got a parenthesis in the wrong place. The very last one doesn't belong (and you don't need the pair around temp == '%' If you're in this kind of situation, start with one thing:

if(yada == '%')
and compile, then add
if(yada == '%' || yada == '.')
compile again
if(yada == '%' || yada == '.' || yada == ';')
etc.

It seems like it will take longer, but you'll be able to keep track of all of the parentheses.

Thankyou so much! =)

I had analyzed your replies and the this problem troubles me, does the integer value when compared to a character always an ASCII code??? I'm very sorry to ask this, I'm just new to programming.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.