+ 3

What is the problem with this structure?

#include <iostream> #include <string> using namespace std; void Sepchr(char*k); void CntWorlds(char*s); void yearlysalary(float i); struct employee{ char name[20]; char family[20]; int person; int age; float salary; void Sepchr (char *k){ for(int i=0;*(k+i)!='\0';i++) { cout << "*(k+i)"; }} void CntWorlds(char *s){ int j=0; for(int i=0;i<strlen(s);i++) { if(isalpha(s[i])) j++; } cout << "\nj"; } void yearlysalary(float i){ float y; y=i*12; cout << ("\n%f",y); } }; int main(){ struct employee p1; cout << "name:"; cin >> p1.name ; cout << "family:"; cin >> p1.family ; cout << "person:"; cin >> p1.person ; cout <<"age:"; cin >> p1.age ; cout << "salary:"; cin >> p1.salary ; Sepchr(p1.name); CntWorlds(p1.family); yearlysalary(p1.salary); return 0; }

8th Oct 2021, 6:05 PM
Mhdis
Mhdis - avatar
2 Answers
+ 3
There are lots of bug in your code strlen () function is a part of string.h header file which belong to c library and you included string header file. Then in line no 36 Where u have used loop in CntWorlds(chars *s ) function here in loop your int variable i=0 is not compatible you need to change it with long unsigned or you can write size_t after that wherr u have written if(isalpha....) inside body cout<<"\n "; here j is unnecessary if u want to print value then u need to write like this cout<<"\n"<<j; Then in void yearlysalary(...) Function u used cout but you printing value of y in c language syntax format which is incorrect u dont need to write%f or any format specifiers to print values. you have two more error but i didn't understood those
8th Oct 2021, 6:53 PM
A S Raghuvanshi
A S Raghuvanshi - avatar