Hey guys, first post here so go easy. Ha.

I am writing a program that needs to take command line arguments, a number and 2 characters.
However, if one of the chars is a command line specific char (such as #, &) it must produce an error.
Does the isgood() function tell which chars are valid or not? or is there a similar function that i could use?

Any help appreciated

> Does the isgood() function tell which chars are valid or not?
> or is there a similar function that i could use?
no, the closest you have is

template<typename char_type> 
  std::ispunct( const char_type&, const std::locale& ) ;

but you could easily write one of your own:

#include <string>

inline bool isgood( char c )
{
  static const std::string bad_chars = "!@#$><&" ; // etc
  return bad_chars.find( c, 0 ) == std::string::npos ;
}

Sounds just like this thread
http://www.daniweb.com/forums/thread115791.html

> if one of the chars is a command line specific char (such as #, &) it must produce an error.
Chances are, the shell will have already used it (see other thread) before it gets to your program.
Unless you quote your shell meta characters in some way, your program won't see them.

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.