okay i try to compile this simple code in Dev C++ and i get some serious errorage
#include <iostream>
using namespace std;
int main()
{
char array[5][5] = {{'a','b','c',' d','e'},
{'f','g','h','i ','j'},
{'k','l','m','n ','o'},
{'p','q','r','s ','t'}
{'u','v','w','x ','y'}};
cout << array[0,0] << endl;
cout << array[1,1] << endl;
cout << array[4,4] << endl;
cin >> array [3,3];
cout << array [3,3];
cin >> array [3,3];
return 0;
}
It giving me 2 parse errors (i have no idea what that is) on my array declaration (it's also giving me an assignment error there too), an "At global Scope" error for my file location and syntax errors for every one of my array calls. Whats the dealio? anyone have any ideas? This is just some test code for a much larger program that uses a big char array to play pong with, and i'm beating my head against a wall because it's due tomorrow at 1pm (oops).
2 1534
#include <iostream.h>
using namespace std;
int main()
{
char array[5][5] = {{'a','b','c',' d','e'},
{'f','g','h','i ','j'},
{'k','l','m','n ','o'},
{'p','q','r','s ','t'} <-- missing coma ","
{'u','v','w','x ','y'}};
cout << array[0,0] << endl;
cout << array[1,1] << endl;
cout << array[4,4] << endl;
cin >> array [3,3];
cout << array [3,3];
cin >> array [3,3];
return 0;
}
what exactly you want to do?
#include <iostream.h>
using namespace std;
int main()
{
char array[5][5] = {{'a','b','c',' d','e'},
{'f','g','h','i ','j'},
{'k','l','m','n ','o'},
{'p','q','r','s ','t'} <-- missing coma ","
{'u','v','w','x ','y'}};
cout << array[0,0] << endl;
cout << array[1,1] << endl;
cout << array[4,4] << endl;
cin >> array [3,3];
cout << array [3,3];
cin >> array [3,3];
return 0;
}
what exactly you want to do?
Actually i figured it out. The point of this program was just to debug and figure out the syntax i need for a bigger program (pong). I went through and i figured it out myself (except for the missing comma, thanks for that!). I was trying to access an element of the array by doing array[1,1] when actually i had to do array[1][1]. You see i'm making a 'gameboard' out of a large 2d char array and having the program move chars around in it to do pong (like it would move the char 'O' around in the array to change the location of the ball) and i wasn't getting anywhere. Now i see my problem *bonk head* thanks for the help though. I'll probably be posting later with other problems i run into tho >_<
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Abby |
last post by:
From my code below, it will open a file specified in argv, then
read line by line and store each line in an array call IPTemp.
After reading until EOF, it will return array IPTemp to main, which
you'll see a for loop here "for(i=0;i<6;i++)" ... I use 6 here,
assuming there's 6 lines in the file I opened. How can I know exactly
how many elements in my array? Please help...thanks a lot.
#include <stdio.h>
|
by: John Smith |
last post by:
I have a two dimentional char array. Before filling it using
strtok(), I reset its elements to '\0' using two nested for loops.
The code works as I hope it would but I wonder whether I really
need to reset the array. The program would run faster if I don't
need to reset.
------------------------------------------
int Array(void)
.................
|
by: rkmoray |
last post by:
I have created a Multi Dimentional array, but having problems filling
it.
int mCount=0;
mCount=ds.Tables.Rows.Count;
string arrayppsa = new string ;
DataTable myDataTable=ds.Tables;
foreach(DataRow myDataRow in myDataTable.Rows) {
|
by: rkmoray |
last post by:
I have created a Multi Dimentional array, but having problems filling
it.
int mCount=0;
mCount=ds.Tables.Rows.Count;
string arrayppsa = new string ;
DataTable myDataTable=ds.Tables;
foreach(DataRow myDataRow in myDataTable.Rows) {
|
by: Max M. Power |
last post by:
I'm getting an InvalidOperationException calling Invoke with a method
parameter object array that contains a two dimentional string array. More
stack trace output below:
// Create two dimentional array.
System::String* tda = new System::String*;
tda = "lastName";
tda = "Power";
tda = "firstName";
tda = "Max";
| |
by: ranjmis |
last post by:
Hi all,
Below is the code wherein I am initializing double dimentional array
inside main with string literals.
Now I want to display the strings using a function call to which I just
want to pass the array as argument with no other info like number of
strings.
Is there a way to achieve that?
|
by: Icarus27 |
last post by:
Hello,
I am making a program that runs off of a two dimentional array but I have made it into a game called MouseBot. I am trying to make the game so that you can move the mouse until you get the cheese. It has four different difficulty levels and you have obsticles in your way (the amount depends on the difficulty level).
The problem I am having is that when I move the 'M' (mousebot) into the array space that the cheese ('C') is in it...
|
by: Srinu |
last post by:
Hi All,
We know the following facts,
1. A two dimentional arrays in C is stored similar to a single
dimentional array.
2. * is the dereference operator that gives value at address denoted
by the operand to this operator. i.e *p is the value at address given
by p.
3. In case of two dimentional array a, a+1 refers to the second
|
by: NvrBst |
last post by:
I'd like to do something like this but having a problem with the
proper syntax in the constructor, maybe someone knows the correct
syntax?
---MyClass.h---
#ifndef MYCLASS_H_
#define MYCLASS_H_
class MyClass {
public:
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |