#include<stdio.h>
#include<conio.h>
#include<string>
#include <iostream>
#include<stdlib.h>
#include "convert.h"

using namespace std;
int check(string);
string send(string);
string hr_str;

int main()
{
    int result=2,n;
    char tt[7];
    char h[2],m[2],s[2];
    cout<<"\nEnter the Time ";
      
    string colon=":";     
    while(result !=1)
    {
      printf("\nHR -> ");
      scanf("%s",h);
    result= check(h);
    }
    
    
  cout<<"\nMain Fun"<<hr_str;
 string t_time;
 strcpy (t_time,hr_str);//-----problem is here
  
 
   
        
    getch();
}

int check(string str)
{
     char *end_ptr;
    long long_var;
    int int_var,i=0;
   // char buff[2]=" ";
   char buff[str.size()];
str.copy(buff,str.size(),0);
     
     long_var = strtol(buff, &end_ptr, 0);
        
        if (ERANGE == errno)
        {
            puts("number out of range\n");
        }
        else if (long_var > INT_MAX)
        {
            printf("%ld too large!\n", long_var);
        }
        else if (long_var < INT_MIN)
        {
            printf("%ld too small!\n", long_var);
        }
        else if (end_ptr == buff)
        {
            printf("not valid numeric input\n");
            return 2;
        }
        
         #if 0
         else if ('\0' != *end_ptr)
         {
                     printf("extra characters on input line\n");
         }
         #endif
        
        else
        {
            int_var = (int)long_var;
            printf("The number %d is OK!\n", int_var);
            
            
            if( int_var>=0 &&  int_var<=9)
            {
                 std::string str = "0" + stringify( int_var);
                 printf("\n1 digit");
                 cout<<"\n"<<str;
                 send(str);
                
            }
            else if( int_var>9 &&  int_var<24)
            {
                printf("\n2 digit");
                 std::string str = stringify( int_var);
                   cout<<"\n"<<str;
                   send(str);
                  
            }
            else if(int_var>23)
            {
                 
                 printf("\nEnter correct value");
                 return 2;
            }        
             return 1;
            
        }
        
            
}



string send(string aaa)
{
       hr_str=aaa;
       
       cout<<"\nin Fun"<<hr_str;
    
}

It gives error
no matching function for call to `strcpy(std::string&, std::string&)'
How to solve it??

strcpy is for C-style strings, not C++ string objects.

>How to solve it??
Change that line to this:

t_time = hr_str;

here it is

#include<iostream.h>
#include<string.h>
void main()
{
char str1[30],str2[30];
int l1,l2,i;

cout<<"enter first string: ";
cin>>str1;
cout<<"enter first string: ";
cin>>str1;

l1=strlen(str1);
l2=strlen(str2);

for(i=0;i<=l2;i++)
{
str1[i]=str2[i];
}
cout<<str1<<endl;
}

Edited 6 Years Ago by peter_budo: Keep it Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

Comments
Why so eager to show off bad code?
nearly two years too late. I doubt the op will care.

@Saba: The code you posted is pretty bad. It uses void main() instead of int main(), uses depreciated header files (c++ no longer uses .h extension in its standard headers), and mixes C and C++ strings, and adds absolutely NOTHING to the thread that has not already been said.

This article has been dead for over six months. Start a new discussion instead.