Exforsys

Online Training

Error in Program

This is a discussion on Error in Program within the C and C++ forums, part of the Programming Talk category; I tried declaring my structure as below in my C programming language: struct test { int x,y; char exa[x][...


Go Back   Exforsys > Programming Talk > C and C++

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-17-2007, 06:17 PM
Senior Member
 
Join Date: Apr 2006
Posts: 125
ashlee is on a distinguished road
Exclamation Error in Program

I tried declaring my structure as below in my C programming language:

struct test {
int x,y;
char exa[x][y];
}test;

I got error when I tried the above test structure. Why is it so? Can someone correct my program?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-18-2007, 05:43 AM
Junior Member
 
Join Date: May 2007
Posts: 9
hvg_99 is on a distinguished road
Answer to your question : Error in program

Question :

struct test {
int x,y;
char exa[x][y];
}test;
Hi,

It so happens that you are trying to declare an array of a variant size and so is the error. The size of the array must be a constant number. You can define a constant and then use that name as the size of the array.

#define MIN 10
#define MAX 50
struct test{
char exa[MIN][MAX];
}test;

int x=10;
int y=20;
struct test {
char exa[x][y];
}test;

I hope i have cleared your doubt.

Gayatri
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) Steve Summit Tech FAQ 0 06-15-2004 07:00 AM
comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) Steve Summit Tech FAQ 0 06-01-2004 07:01 AM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit Tech FAQ 0 06-01-2004 07:00 AM
comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) Steve Summit Tech FAQ 0 05-15-2004 07:00 AM
Apple II Csa2 FAQs: Telecom Hardware & Transfers, Part 20/25 rubywand@swbell.net Tech FAQ 0 04-04-2004 08:29 AM


All times are GMT -4. The time now is 12:00 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.