473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Beginner Help, Win 32

Hello, I am new to c++ Win32 coding, actually this is the first time
Ive really tried to make a program with it. I was trying to create a
"love calculator" program, this exerpt is tha part which compares the
length of the 2 different names. It does not compile, and instead
gives me 3 errors and 4 warnings, could someone please tell me what I
am doing wrong? Help would be greatly appreciated.

Errors/Warnings:

Warning 1 warning C4267: 'initializing' : conversion from 'size_t' to
'int', possible loss of data
Warning 2 warning C4018: '<' : signed/unsigned mismatch
Warning 3 warning C4267: 'initializing' : conversion from 'size_t' to
'int', possible loss of data
Warning 4 warning C4018: '<' : signed/unsigned mismatch116
Error 5 error C3867: 'std::basic_string<_Elem,_Traits,_Ax>::length':
function call missing argument list; use
'&std::basic_string<_Elem,_Traits,_Ax>::length' to create a pointer to
member
Error 6 error C2446: '==' : no conversion from '__w64 unsigned int' to
'__w64 unsigned int (__thiscall std::basic_string<_Elem,_Traits,_Ax>::*
)(void) const'
Error 7 error C2040: '==' : '__w64 unsigned int (__thiscall
std::basic_string<_Elem,_Traits,_Ax>::* )(void) const' differs in
levels of indirection from '__w64 unsigned int'

Code:
int Calculate(string p1FirstName, string p1LastName, string
p2FirstName, string p2Lastname, string p1Sex, string p2Sex)
{
int Percentage = 0;
if (p1FirstName.length() p2FirstName.length())
{
int x = p2FirstName.length();
int i = 10;
while ( x < p1FirstName.length() )
{
x++;
i--;
}
Percentage += i;
}
else if (p1FirstName.length() < p2FirstName.length())
{
int x = p1FirstName.length();
int i = 10;
while ( x < p2FirstName.length() )
{
x++;
i--;
}
Percentage += i;

}
else if (p1FirstName.length == p2FirstName.length())
{
Percentage += 10;
}
return Percentage;
}

Sep 1 '06 #1
4 4810
aj
check your last "else if". Your first call to length on this line is
missing the "()".

-- AJ
PhreakRox wrote:
Hello, I am new to c++ Win32 coding, actually this is the first time
Ive really tried to make a program with it. I was trying to create a
"love calculator" program, this exerpt is tha part which compares the
length of the 2 different names. It does not compile, and instead
gives me 3 errors and 4 warnings, could someone please tell me what I
am doing wrong? Help would be greatly appreciated.

Errors/Warnings:

Warning 1 warning C4267: 'initializing' : conversion from 'size_t' to
'int', possible loss of data
Warning 2 warning C4018: '<' : signed/unsigned mismatch
Warning 3 warning C4267: 'initializing' : conversion from 'size_t' to
'int', possible loss of data
Warning 4 warning C4018: '<' : signed/unsigned mismatch116
Error 5 error C3867: 'std::basic_string<_Elem,_Traits,_Ax>::length':
function call missing argument list; use
'&std::basic_string<_Elem,_Traits,_Ax>::length' to create a pointer to
member
Error 6 error C2446: '==' : no conversion from '__w64 unsigned int' to
'__w64 unsigned int (__thiscall std::basic_string<_Elem,_Traits,_Ax>::*
)(void) const'
Error 7 error C2040: '==' : '__w64 unsigned int (__thiscall
std::basic_string<_Elem,_Traits,_Ax>::* )(void) const' differs in
levels of indirection from '__w64 unsigned int'

Code:
int Calculate(string p1FirstName, string p1LastName, string
p2FirstName, string p2Lastname, string p1Sex, string p2Sex)
{
int Percentage = 0;
if (p1FirstName.length() p2FirstName.length())
{
int x = p2FirstName.length();
int i = 10;
while ( x < p1FirstName.length() )
{
x++;
i--;
}
Percentage += i;
}
else if (p1FirstName.length() < p2FirstName.length())
{
int x = p1FirstName.length();
int i = 10;
while ( x < p2FirstName.length() )
{
x++;
i--;
}
Percentage += i;

}
else if (p1FirstName.length == p2FirstName.length())
{
Percentage += 10;
}
return Percentage;
}
Sep 1 '06 #2
Thankyou for your help, however im still experiancing one more problem.
The percentage I return does not seem to display. I was just
wondering if I was using ostringstream correctly.

I tried both this:

std::ostringstream strstream;
strstream << "Full Name: " + Response[0] + " " + Response[1] + " your
compatibility with " + Response[3] + " " + Response[4] + " is " <<
percent.c_str() << "%";
echo(strstream.str(), 1);

and this:
std::ostringstream strstream;
strstream << "Full Name: " + Response[0] + " " + Response[1] + " your
compatibility with " + Response[3] + " " + Response[4] + " is " <<
percent << "%";
echo(strstream.str(), 1);

Sep 2 '06 #3
"PhreakRox" <Ph*******@gmail.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
Thankyou for your help, however im still experiancing one more problem.
The percentage I return does not seem to display. I was just
wondering if I was using ostringstream correctly.

I tried both this:

std::ostringstream strstream;
strstream << "Full Name: " + Response[0] + " " + Response[1] + " your
compatibility with " + Response[3] + " " + Response[4] + " is " <<
percent.c_str() << "%";
strstream << "Full Name: " << Response[0] << " " << Response[1] << " etc.";

HTH,
Stu

P.S. I wouldn't call it strstream, there's something in the standard library
called that and it could be confusing :)

<snip>
Sep 2 '06 #4
Thankyou for your help stuart, that did the trick for me

Stuart Golodetz wrote:
"PhreakRox" <Ph*******@gmail.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
Thankyou for your help, however im still experiancing one more problem.
The percentage I return does not seem to display. I was just
wondering if I was using ostringstream correctly.

I tried both this:

std::ostringstream strstream;
strstream << "Full Name: " + Response[0] + " " + Response[1] + " your
compatibility with " + Response[3] + " " + Response[4] + " is " <<
percent.c_str() << "%";

strstream << "Full Name: " << Response[0] << " " << Response[1] << " etc.";

HTH,
Stu

P.S. I wouldn't call it strstream, there's something in the standard library
called that and it could be confusing :)

<snip>
Sep 2 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Art | last post by:
NEWBIE ALERT! Esteemed List Participants and Lurkers: (System: P-II 350, 192 meg, Win98 SE, Python 2.2.3, wxPythonWIN32-2.4.1.2-Py22.exe) I'm having a lot of fun getting started with Python...
3
by: jvax | last post by:
Hi all, I hope I'm posting in the right NG... I have a data text file I want to read from a c++ program. the data file goes like this: 90 # number of balls 33 42 13
8
by: Grrrbau | last post by:
I'm a beginner. I'm looking for a good C++ book. Someone told me about Lafore's "Object-Oriented Programming in C++". What do you think? Grrrbau
1
by: LRW | last post by:
I was wondering if anyone could recommend some good beginner sites and tutorial sites for writting ASP.Net pages in C#. Things that especially help with datagrids!! And, are there additional...
14
by: z_learning_tester | last post by:
But I can't seem to find the answer. The question is how do you reverse the words in a string? Or how do you reverse the numbers listed in a string? The example is usually something like: Turn...
3
by: William Foster | last post by:
Good evening all, Microsoft is really starting to annoy me as a new user. I am trying to convert my code from VBA (A very user friendly laguage with generally good help files) to Visual Studio...
10
by: See_Red_Run | last post by:
Hi, I am trying to figure out how to get started with PHP/MySQL. Everything I've read so far says to start with PHP first. I was expecting something like Visual Basic Express or some other type...
1
by: Blue_hatter | last post by:
Hey Guys, I'm a newbie to the whole C++ Programming thing as I think I said before in a post. The thing is, I have this idea that might help me to learn at a better pace than I am doing currently....
10
by: hamza612 | last post by:
I want to start learning how to program. But I dont know where to start. From what I've heard so far c++ is not a good lang. to learn as a beginner because its very complicated compared to others...
22
by: ddg_linux | last post by:
I have been reading about and doing a lot of php code examples from books but now I find myself wanting to do something practical with some of the skills that I have learned. I am a beginner php...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.