473,396 Members | 2,139 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.

double array code fails

Hi all. The following code gives the error below. I'm coding against
minGW. I would appreciate it if someone could tell me where I have
gone wrong.

/*********************************** code
*******************************************/
#include <iostream>
using namespace std;

int main(){
string dogs[][] = { {"terry", "brown"} ,
{"Kristin", "white"} ,
{"toby", "gray"},
{"fido", "black"}
};
cout<<dogs[0][0]<<endl;
}

/******************************** error message
**********************************/

C:\unisa\MyFiles\Test_bin\simple_double_array_outp ut.cpp
[Warning] In function `int main()':
error C:\unisa\MyFiles\Test_bin\simple_double_array_outp ut.cpp:5
declaration of `dogs' as multidimensional array must have bounds for
all dimensions except the first
error C:\unisa\MyFiles\Test_bin\simple_double_array_outp ut.cpp:10
`dogs' undeclared (first use this function)
[Build Error] (Each undeclared identifier is reported only once for
each function it appears in.)

/
************************************************** **********************************/

Oct 20 '07 #1
5 4181
Hi,
Just doing what the error message told you to do (and adding string as
header):
#include <iostream>
#include <string>
using namespace std;

int main(){
string dogs[][2] = { {"terry", "brown"} ,
{"Kristin", "white"} ,
{"toby", "gray"},
{"fido", "black"}
};
cout<<dogs[0][0]<<endl;
cout<<dogs[0][1]<<endl;
}

Regards, Ron AF Greve

http://www.InformationSuperHighway.eu

"CodeGrommet" <ri*********@gmail.comwrote in message
news:11*********************@t8g2000prg.googlegrou ps.com...
Hi all. The following code gives the error below. I'm coding against
minGW. I would appreciate it if someone could tell me where I have
gone wrong.

/*********************************** code
*******************************************/
#include <iostream>
using namespace std;

int main(){
string dogs[][] = { {"terry", "brown"} ,
{"Kristin", "white"} ,
{"toby", "gray"},
{"fido", "black"}
};
cout<<dogs[0][0]<<endl;
}

/******************************** error message
**********************************/

C:\unisa\MyFiles\Test_bin\simple_double_array_outp ut.cpp
[Warning] In function `int main()':
error C:\unisa\MyFiles\Test_bin\simple_double_array_outp ut.cpp:5
declaration of `dogs' as multidimensional array must have bounds for
all dimensions except the first
error C:\unisa\MyFiles\Test_bin\simple_double_array_outp ut.cpp:10
`dogs' undeclared (first use this function)
[Build Error] (Each undeclared identifier is reported only once for
each function it appears in.)

/
************************************************** **********************************/

Oct 20 '07 #2
Hm,

and it would be a good habbit to add

return 0;

At the end (indicating no error as return value)
Regards, Ron AF Greve

http://www.InformationSuperHighway.eu

"Ron AF Greve" <ron@localhostwrote in message
news:47*********************@news.xs4all.nl...
Hi,
Just doing what the error message told you to do (and adding string as
header):
#include <iostream>
#include <string>
using namespace std;

int main(){
string dogs[][2] = { {"terry", "brown"} ,
{"Kristin", "white"} ,
{"toby", "gray"},
{"fido", "black"}
};
cout<<dogs[0][0]<<endl;
cout<<dogs[0][1]<<endl;
}

Regards, Ron AF Greve

http://www.InformationSuperHighway.eu

"CodeGrommet" <ri*********@gmail.comwrote in message
news:11*********************@t8g2000prg.googlegrou ps.com...
>Hi all. The following code gives the error below. I'm coding against
minGW. I would appreciate it if someone could tell me where I have
gone wrong.

/*********************************** code
*******************************************/
#include <iostream>
using namespace std;

int main(){
string dogs[][] = { {"terry", "brown"} ,
{"Kristin", "white"} ,
{"toby", "gray"},
{"fido", "black"}
};
cout<<dogs[0][0]<<endl;
}

/******************************** error message
**********************************/

C:\unisa\MyFiles\Test_bin\simple_double_array_out put.cpp
[Warning] In function `int main()':
error C:\unisa\MyFiles\Test_bin\simple_double_array_outp ut.cpp:5
declaration of `dogs' as multidimensional array must have bounds for
all dimensions except the first
error C:\unisa\MyFiles\Test_bin\simple_double_array_outp ut.cpp:10
`dogs' undeclared (first use this function)
[Build Error] (Each undeclared identifier is reported only once for
each function it appears in.)

/
************************************************* ***********************************/


Oct 20 '07 #3
On 2007-10-20 16:18, CodeGrommet wrote:
Hi all. The following code gives the error below. I'm coding against
minGW. I would appreciate it if someone could tell me where I have
gone wrong.
What part of
declaration of `dogs' as multidimensional array must have bounds for
all dimensions except the first
is it that you do not understand?

BTW: you need to include <stringto get the printing to work.

--
Erik Wikström
Oct 20 '07 #4
Thank you very much :)
Oct 20 '07 #5
btw, the code runs without the string include.

Oct 20 '07 #6

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

Similar topics

4
by: Venkat | last post by:
Hi All, I need to copy strings from a single dimensional array to a double dimensional array. Here is my program. #include <stdio.h> #include <stdlib.h>
1
by: apm | last post by:
Is there a way to go from a pointer to an unmanaged array of double to a managed Array of Double without having to copy the values? The unmanaged code calls back into managed code. The unmanaged...
2
by: Yogi21 | last post by:
Hi I have a sorted array containing strings. I am iterating through the array and clearing the contents one by one using "array.BinarySearch" to find each element. So far so good. But the moment I...
5
by: mark | last post by:
I know I am being incredibly dunderheaded about this consider the following: STRICT ON Dim a(,) As Double = {{1, 2}, {3, 4}, {5, 6}} Private Sub T1(ByVal a As Array) Dim i, j As Integer For i =...
0
by: jim4u | last post by:
I am porting a vb library to vb.net. The vb library has an external call to an unmanaged dll. Existing code: //External function declaration Private Declare Function Uncompress& Lib...
0
by: jim4u | last post by:
I am porting a vb library to vb.net. The vb library has an external call to an unmanaged dll. Existing code: //External function declaration Private Declare Function Uncompress& Lib...
8
by: Protoman | last post by:
Why doesn't my double bubble sort algorithm sort; it just spits the numbers out, int the exact same order that I inputted them. Code: void swap(int& i,int& j) { i^=j; j^=i; i^=j;
1
by: Peterwkc | last post by:
Hello all expert, i have two program which make me desperate bu after i have noticed the forum, my future is become brightness back. By the way, my problem is like this i the first program was...
2
by: cendter | last post by:
Hi there, I am utterly confused - I have a form that starts an instance from excel and let's the user select a range. I then want to take this range as an array of doubles. I ran into trouble...
2
by: anon.asdf | last post by:
Hi! Q. 1) How does one write: sizeof(array of 5 "pointers to double") ??? I know that sizeof(pointer to an array of 5 doubles) can be written as: sizeof(double (*));
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: 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
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
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
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.