CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13

Threaded View

  1. #1
    Join Date
    Nov 2009
    Posts
    10

    Determine if a string is composed of numbers or characters

    I have pulled a string from an input, and I have to execute a function on it depending on if the string is numbers or characters. I tried making a function file that can determine it, however I am getting an illegal expression error C2451:

    Code:
    int chooseMethod (string testStr){
    
    for (int I = 0; I<10; I++){
    	if (testStr.substr(1,1) = I){
    		return 2;}}
    
    return 1;
    
    }
    Then based on the return I use the corresponding function. The error lies within
    Code:
    if (testStr.substr(1,1) = I)
    . What am I doing wrong, or is there a common/easier way to do this?
    Last edited by HeliPilot; December 7th, 2009 at 03:05 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured