I have a string function written in rtstring.c file which simply accept a string and return back the same string. Then i have included this file in a body.cpp file and i want to pass string from this file to c file. How can I do this please help
My code
rtstring.c
#include <stdio.h>
char * rtstr(char * s)
{
return s;
}
body.cpp
#pragma once
#include "header.h"
#include "rtstring.c"
mystring::mystring(string str)
{
st=str;
}
string mystring::strreturn(string s1)
{
st=rtstr(s1);
return st;
}
header.h
#pragma once
class mystring
{
public:
mystring(string a);
string strreturn(string s1);
private:
string st;
}
main.cpp
#include <iostream>
using namespace std;
#include "header.h"
int main()
{
string rs,s="hi hello";
mystring str1(s);
rs=str.strreturn(s);
cout<<"string from c"<<rs;
return 0;
}
I an getting an error of return type mismatch and many associated error. Please help if there is anyway to deal with it. an example will be helpfull. Thanks in advance