473,394 Members | 1,811 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,394 software developers and data experts.

Where's my C2061?

arrayStr and intString are both failing a C2061 error

// median.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;

int main()
{
string arrayStr = "";
string intString = "";

cout << "Enter an array of integers" << endl;

do
cin >> intString;
C2061 arrayStr = arrayStr + intString + " ";
C2061 while intString != "";

cout << arrayStr << endl;

return 0;
}

A better question would be how do I enter a string of numbers separated by
spaces? I need a variable length array of integers.

And, why has Studio.NET stopped "Please press any key to continue" in the
command prompt window?

I haven't done C++ programming in a while and I'm having more trouble than I
ever had when I was first learning.
May 12 '06 #1
2 960
plains5728 wrote:
arrayStr and intString are both failing a C2061 error

// median.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;

int main()
{
string arrayStr = "";
string intString = "";

cout << "Enter an array of integers" << endl;

do
cin >> intString;
C2061 arrayStr = arrayStr + intString + " ";
C2061 while intString != "";

cout << arrayStr << endl;

return 0;
}

A better question would be how do I enter a string of numbers separated by
spaces? I need a variable length array of integers.

And, why has Studio.NET stopped "Please press any key to continue" in the
command prompt window?

I haven't done C++ programming in a while and I'm having more trouble than I
ever had when I was first learning.


plains:

Your do-while syntax is wrong:

do
{
cin >> intString;
arrayStr = arrayStr + intString + " ";
}
while (intString != "");

You might want to look at std::getline().

"Please press any key to continue" does not appear when you run under
the debugger.

David Wilkinson
May 12 '06 #2
I'm programming in Visual Basic again. The pitfalls of being multi-lingual.
Thanks.

"David Wilkinson" wrote:
plains5728 wrote:
arrayStr and intString are both failing a C2061 error

// median.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;

int main()
{
string arrayStr = "";
string intString = "";

cout << "Enter an array of integers" << endl;

do
cin >> intString;
C2061 arrayStr = arrayStr + intString + " ";
C2061 while intString != "";

cout << arrayStr << endl;

return 0;
}

A better question would be how do I enter a string of numbers separated by
spaces? I need a variable length array of integers.

And, why has Studio.NET stopped "Please press any key to continue" in the
command prompt window?

I haven't done C++ programming in a while and I'm having more trouble than I
ever had when I was first learning.


plains:

Your do-while syntax is wrong:

do
{
cin >> intString;
arrayStr = arrayStr + intString + " ";
}
while (intString != "");

You might want to look at std::getline().

"Please press any key to continue" does not appear when you run under
the debugger.

David Wilkinson

May 13 '06 #3

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

Similar topics

47
by: Andrey Tatarinov | last post by:
Hi. It would be great to be able to reverse usage/definition parts in haskell-way with "where" keyword. Since Python 3 would miss lambda, that would be extremly useful for creating readable...
3
by: A.V.C. | last post by:
Hello, I found members of this group very helpful for my last queries. Have one problem with CASE. I can use the column name alias in Order By Clause but unable to use it in WHERE CLAUSE. PLS...
3
by: Xiangliang Meng | last post by:
Hi, all. In 1998, I graduated from Computer Science Dept. in a university in China. Since then, I've been using C Language for almost 6 years. Although I'm using C++ in my current job, I'm also...
0
by: MWK | last post by:
Hi All, I don't understand why I get "error c2061: syntax error : identifier" in VS2003. I thought it's fixed in .Net 2003: __hook(&TCP_Client::LineReceived, client, HandlerLineReceived); ...
7
by: Britney | last post by:
Original code: this.oleDbSelectCommand1.CommandText = "SELECT TOP 100 user_id, password, nick_name, sex, age, has_picture, city, state, " + "country FROM dbo.users WHERE (has_picture = ?) AND (sex...
5
by: comp.lang.php | last post by:
if ($willLimitByDB) $sql = preg_replace('/#(+)#/i', '$$1', $sql); This does not give me the results I want, instead of the value of $where in $sql, I literally get '$where' instead. How do I...
5
by: John | last post by:
I just cannot manage to perform a SELECT query with NULL parameter... My CATEGORY table does have one row where TCATEGORYPARENTID is null (real DB null value). TCATEGORYID and TCATEGORYPARENTID...
6
by: Pixel.to.life | last post by:
So I have this perfectly fine and running app, that uses managed C++ forms. Problem#1: I pass a Bitmap reference to a class, hoping to modify it in one of the class's methods, so it reflects...
15
by: madhu.ab | last post by:
Hi All, I am getting the following errors when i am including header file winuser.h I dont know whats happening. How will an error occur in winuser.h?? Please help. \microsoft visual...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.