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

Bad array Declarator

I have to create an array of 10 strings and put 10 quotes in each. I also have to create a while loop which I don't know where to start. I am having trouble compiling and I can't find any of this online.. Its driving me crazy - I am new to programming.

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.IO;
  7. #include "stdafx.h"
  8. #include <string>
  9. string Quote;
  10. using namespace std;
  11.  
  12.  
  13.  
  14. int main()
  15. {
  16.     // String Array
  17.     string Quote[9];
  18.     // Attach Values
  19.     Quote[0] = "Don't cry because it's over, smile because it happened.";
  20.     Quote[1] = "Be yourself; everyone else is already taken.";
  21.     Quote[2] = "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe.";
  22.     Quote[3] = "A room without books is like a body without a soul.";
  23.     Quote[4] = "You know you're in love when you can't fall asleep because reality is finally better than your dreams.";
  24.     Quote[5] = "You only live once, but if you do it right, once is enough.";
  25.     Quote[6] = "If you tell the truth, you don't have to remember anything.";
  26.     Quote[7] = "A friend is someone who knows all about you and still loves you.";
  27.     Quote[8] = "To live is the rarest thing in the world. Most people exist, that is all.";
  28.     Quote[9] = "Without music, life would be a mistake.";
  29.     return 0
  30. }
It says bad array decorator when it says string Quote[9]
Aug 12 '18 #1
3 1843
zmbd
5,501 Expert Mod 4TB
It has been awhile since I've used C
I am most likely wrong; however, I am not sure that line 9 is needed...

I also think you need (most likely the error):
string Quote[10];

and I always used the typedef
typedef char * string;

Sorry I don't have a C compiler installed so I can't double check - WeaknessForCats will be along soon and will know the answer

Thank you for showing your work - normally we will not answer homework type problems unless the poster has shown that they've made an effort to solve the problem on their own first :-)
!Two Thumbs Up!
Aug 12 '18 #2
weaknessforcats
9,208 Expert Mod 8TB
You created an array of 9.

That would be elements 0,1,2,3,4,5,6,7,8.
Aug 14 '18 #3
dev7060
636 Expert 512MB
As per the requiments, you can use a 2D character array. Quote[x][y] , here x is 10 but y needs to be mentioned (size of the maximum length quote).

Implementation for outputting:

Expand|Select|Wrap|Line Numbers
  1. for (i=0; i<x; i++){
  2.    printf("%s", Quote[i]);
  3. }
  4.  
Aug 18 '18 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Gil | last post by:
Hope this is the right group to post to. I compiled C++ code that ran fine on Windows with VisualStudio 6.0. I then moved the code to Solaris 9 and compiled with g++, but am getting the...
7
by: xxx | last post by:
I am having difficulty seeing why cv_qualifier, which is used as a type specifier in the declaration section of the ISO/IEC grammar, is defined in the declarator section. A declaration can consist...
8
by: Frank Münnich | last post by:
Hi there.. My name is Frank Münnich. I've got a question about pointers that refer to an array of a structure. How do I declare that type? If I have declared a structure struct mystruc {...
0
by: Alex Sedow | last post by:
Standart describe grammar for events as (in EBNF): event-declaration: "event" type variable-declarators ";" "event" type member-name "{" event-accessor-declarations "}" ...
7
by: anjogasa | last post by:
In the midst of reading "The C++ Programming Language", the latest edition by Stroustrup, and I find myself butting my head against a few paragraphs. I have searched the errata on the website, and...
5
by: Remco van Engelen | last post by:
Hello, I have a question regarding the ISO C grammar. The syntax of a direct-declarator reads (section A.2.2, page 413 in my copy; the (R1) is just to 'name' the rule for later reference): ...
4
by: werasm | last post by:
Hi all, I have recently come accross this function declaration syntax. Initially it was puzzling (still is, to be honest), but I now realize that it declares a function that returns a reference...
18
by: mdh | last post by:
>From p112 ( K&R). Given an array declared as static char arr= { { 0,1,........},{0,1,.....}}; let arr be passed as an argument to f. f( int (*arr) ) {....} It is noted that the...
7
by: arnuld | last post by:
this programme gives unusual output. i am not able to find out where the semantic bug lies: /* C++ Primer - 4/e * * an example from section section 7.2.4, page 241 * STATEMENT * write a...
10
by: mdh | last post by:
Sorry in advance if this is really dumb, but I am trying to get my head around exactly what the declarator is. In the FAQ, 1.21, part of it says "C declarations ....come in 2 parts, a base type and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
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: 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...

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.