Wrox Programmer Forums
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old May 31st, 2007, 05:34 PM
Registered User
 
Join Date: May 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Arrays Error

Hi!
I`ve got some problems with my arrays. This is piece of my program:

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

using namespace std;

string zakoduj(string co);

void main()
{
    int iLicz=0;
    int iPozycja=0;
    int iOstatni=0;
    char cKoncowy;
    char aTablica1[64];

    aTablica1[0]='a';
    aTablica1[1]='b';
    aTablica1[2]='c';
    aTablica1[3]='d';
    aTablica1[4]='e';
    aTablica1[5]='f';
    aTablica1[6]='g';
    aTablica1[7]='h';
    aTablica1='i';
    aTablica1[9]='j';
    aTablica1[10]='k';
    aTablica1[11]='l';
    aTablica1[12]='m';
    aTablica1[13]='n';
    aTablica1[14]='o';
    aTablica1[15]='p';
    aTablica1[16]='r';
    aTablica1[17]='s';
    aTablica1[18]='t';
    aTablica1[19]='u';
    aTablica1[20]='w';
    aTablica1[21]='z';
    aTablica1[22]='x';
    aTablica1[23]='y';
    aTablica1[24]='q';
    aTablica1[25]='v';
    aTablica1[26]='0';
    aTablica1[27]='1';
    aTablica1[28]='2';
    aTablica1[29]='3';
    aTablica1[30]='4';
    aTablica1[31]='5';
    aTablica1[32]='6';
    aTablica1[33]='7';
    aTablica1[34]='8';
    aTablica1[35]='9';
    aTablica1[36]=',';
    aTablica1[37]='.';
    aTablica1[38]='//';
    aTablica1[39]='<';
    aTablica1[40]='>';
    aTablica1[41]='?';
    aTablica1[42]=';';
    aTablica1[43]='\'';
    aTablica1[44]=':';
    aTablica1[45]='[';
    aTablica1[46]=']';
    aTablica1[47]='\';
    aTablica1[48]='{';
    aTablica1[49]='}';
    aTablica1[50]='|';
    aTablica1[51]='-';
    aTablica1[52]='=';
    aTablica1[53]='_';
    aTablica1[54]='+';
    aTablica1[55]='!';
    aTablica1[56]='@';
    aTablica1[57]='#';
    aTablica1[58]='$';
    aTablica1[59]='%';
    aTablica1[60]='^';
    aTablica1[61]='&';
    aTablica1[62]='*';
    aTablica1[63]='(';
    aTablica1[64]=')';


}

And when i`m compiling my code, the c++ gives me an errors:
(4) : error C2015: too many characters in constant
(4) : error C2006: '#include' : expected a filename, found 'constant'

What am i doing wrong?

Paul

Reply With Quote
  #2 (permalink)  
Old June 5th, 2007, 12:52 AM
Registered User
 
Join Date: Apr 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

first of all include the stdafx file in double quotes
#include "stdafx.h".I don't think that it is necessary to include this file in ur program. Removing it will not cause u any trouble.
Also u have declared the array as char aTablica1[64];
and u have initialized the array elements from
aTablical[0]-aTablical[64]. It must be till aTablical[63].
Note the when working with arrays the upperbound is always 1 less than
the actual size of the array since the first array element begins at position 0. Note that it is not an error to initialize ur array outside its boundaries the compiler will not issue an error for this.
Also check for this statement this may be the place where u r getting error.
aTablica1[38]='//';Try removing one of the forward slash from it.


Reply With Quote
  #3 (permalink)  
Old June 6th, 2007, 11:27 AM
Authorized User
 
Join Date: Oct 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Also,
Change the following:
aTablica1[47]='\';
to
aTablica1[47]='\\';


Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
Multidemmesional Arrays OR arrays gmoney060 Classic ASP Basics 3 November 1st, 2004 03:42 PM
Arrays llewellynj Excel VBA 3 July 8th, 2003 05:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.