U
urbman
I am trying to alter a few functions in this basic code, but I am
stuck. I am getting these errors. Any help you can provide would be
greatly appreciated. Thanks.
c:\documents and settings\urbanp\desktop
\cps130\module1\urban1\urban1.cpp(24) : warning C4700: uninitialized
local variable 'len' used
Linking...
urban1.obj : error LNK2019: unresolved external symbol "void __cdecl
getname(class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> >)" (?getname@@YAXV?
$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
referenced in function _main
C:\Documents and Settings\urbanp\Desktop\CPS130\module1\urban1\Debug
\urban1.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\Documents and Settings\urbanp\Desktop
\CPS130\module1\urban1\Debug\BuildLog.htm"
urban1 - 2 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
==========
It's sort of pissing me off because I normally can figure these out.
My code looks like this:
// Program to Demonstrate Functions that Return One Value
// Filename: fun8.cpp
// Replace the getinfo function with two separate functions
// One should getname and another to getlength
// Save this file with the new changes as fun9.cpp
#include <iostream>
#include <string>
#include<string.h>
using namespace std;
void getname(string name);
void getlength(string name, int len);
void display(string name, int len);
void displaystars(int len);
int main()
{
string name;
int len;
getname(name);
display(name, len);
return 0;
}
void getname(string & name, int & len)
{
cout << "Enter your name : ";
getline(cin,name);
getlength(name, len);
}
void getlength(string name, int len)
{
len = name.length();
}
void display(string name, int len)
{
displaystars(len);
cout << name << endl;
displaystars(len);
}
void displaystars(int len)
{
for (int i = 1; i <= len; i++)
cout << '*';
cout << endl;
}
stuck. I am getting these errors. Any help you can provide would be
greatly appreciated. Thanks.
c:\documents and settings\urbanp\desktop
\cps130\module1\urban1\urban1.cpp(24) : warning C4700: uninitialized
local variable 'len' used
Linking...
urban1.obj : error LNK2019: unresolved external symbol "void __cdecl
getname(class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> >)" (?getname@@YAXV?
$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
referenced in function _main
C:\Documents and Settings\urbanp\Desktop\CPS130\module1\urban1\Debug
\urban1.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\Documents and Settings\urbanp\Desktop
\CPS130\module1\urban1\Debug\BuildLog.htm"
urban1 - 2 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
==========
It's sort of pissing me off because I normally can figure these out.
My code looks like this:
// Program to Demonstrate Functions that Return One Value
// Filename: fun8.cpp
// Replace the getinfo function with two separate functions
// One should getname and another to getlength
// Save this file with the new changes as fun9.cpp
#include <iostream>
#include <string>
#include<string.h>
using namespace std;
void getname(string name);
void getlength(string name, int len);
void display(string name, int len);
void displaystars(int len);
int main()
{
string name;
int len;
getname(name);
display(name, len);
return 0;
}
void getname(string & name, int & len)
{
cout << "Enter your name : ";
getline(cin,name);
getlength(name, len);
}
void getlength(string name, int len)
{
len = name.length();
}
void display(string name, int len)
{
displaystars(len);
cout << name << endl;
displaystars(len);
}
void displaystars(int len)
{
for (int i = 1; i <= len; i++)
cout << '*';
cout << endl;
}