String tel_s is not printing in "conv" function from line no: 76... I m sending tel_s from main to "void conv" which is assigned value there..
Code:
#include <iostream>
using namespace std;
void conv(string& age_s, string& tel_s, int& age, int& tel, int age_len, int tel_len);
int intlen(int a);
void inpt(string& fname, string& lname, string& add, int& age, int& tel);
int main()
{
string fname, lname, add, age_s, tel_s;
int age, tel, age_len, tel_len;
float sall=0.00;
inpt(fname,lname,add,age,tel);
age_len=intlen(age);
tel_len=intlen(tel);
//cout << tel_len << endl << age_len << endl;
conv(age_s,tel_s,age,tel,age_len,tel_len);
cout << fname << endl;
cout << lname << endl;
cout << add << endl;
//cout << tel_s << "hi" << endl;
return 0;
}
void inpt(string& fname, string& lname, string& add, int& age, int& tel)
{
cout << "Enter First name: ";
getline(cin,fname);
cout << "Enter Last name: ";
getline(cin, lname);
cout << "Enter Address: ";
getline(cin, add);
cout << "Enter Telephone no: ";
cin >> tel;
cout << "Enter age: ";
cin >> age;
}
int intlen(int a)
{
int b = 0;
while(a > 0)
{
a = a/10;
b++;
}
return b;
}
void conv(string& age_s, string& tel_s, int& age, int& tel, int age_len, int tel_len)
{
int temp=0, i=0,j=0;
temp=tel;
int div=1;
char tel_c;
for (j=0;j < (tel_len-1);j++){
div=1;
for (i=0; i<((tel_len)-(j+1)); i++)
{
div=div*10;
}
temp =(temp/div);
cout << "temp: " <<temp << endl << "div: " << div<< endl;
tel_c=temp+47;
tel_s[j]=tel_c;
temp=tel%div;
}
cout << "his" << tel_s;
}