473,385 Members | 2,004 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,385 software developers and data experts.

debug prob..

im not able to figure out the error.. can someone help me with this..
the code is..
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <string.h>
  4.  
  5. #define MAX_STATES    20
  6. #define MAX_VARS    5
  7. #define MAX_TRANS    10         
  8. #define MAX_LEN        20
  9.  
  10. struct  TransTbl
  11. {
  12.     char trans[MAX_TRANS];
  13.     int nt;    
  14. };
  15.  
  16. struct TransTbl tt[MAX_STATES][MAX_VARS];
  17. char vars[MAX_VARS];
  18. char re[MAX_LEN];
  19. int NS = 0;        //keeps count of states..
  20. int nv;            //no of vars..
  21.  
  22. /*initialize nt for the objects..*/
  23. int i,j;
  24. for(i=0; i<MAX_STATES; i++)
  25.     for(j=0; j<MAX_VARS; j++)
  26.         tt[i][j].nt = 0;
  27.  
  28.  
the error : syntax error befor for
Mar 18 '07 #1
5 1197
horace1
1,510 Expert 1GB
for() is an executable statement so can only occur in a function, e.g. in main()
Expand|Select|Wrap|Line Numbers
  1. int main()
  2. {
  3. for(i=0; i<MAX_STATES; i++)
  4.     for(j=0; j<MAX_VARS; j++)
  5.         tt[i][j].nt = 0;
  6.  
  7.  
Mar 18 '07 #2
hey thanks a lot!
it worked!
Mar 18 '07 #3
now another problem..
im pretty sure im allowed to do this but i may be wrong..
the code..

printf("Enter no of vars : ");
scanf("%d", &nv);

printf("Enter vars..");
for(i=0; i<nv; i++)
scanf("%c", vars[i]);
vars[i] = 'E';

when i give input for "vars" it crashes.. and the "nv" i gave was 2.
btw the declaration(global) of vars is char vars[MAX_VARS] where max vars is 5

what am i doing wrong..
Mar 18 '07 #4
arne
315 Expert 100+
now another problem..
im pretty sure im allowed to do this but i may be wrong..
the code..

printf("Enter no of vars : ");
scanf("%d", &nv);

printf("Enter vars..");
for(i=0; i<nv; i++)
scanf("%c", vars[i]);
vars[i] = 'E';

when i give input for "vars" it crashes.. and the "nv" i gave was 2.
btw the declaration(global) of vars is char vars[MAX_VARS] where max vars is 5

what am i doing wrong..

Try '&vars[i]' instead of 'vars[i]' in the scanf.
Mar 18 '07 #5
thanks a lot! it works
i also had to change the "%c" to "%s"
Mar 18 '07 #6

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

Similar topics

6
by: josephrthomas | last post by:
hi..i am trying to make a login page and i am using access table.. when the user enters his userid and password i want to check the password from the table.. if any user with the userID that is...
29
by: Thomas | last post by:
Hi I have an XSL stylesheet: <xsl:for-each select="TRACKS/TRACK"> <tr class="TDL"> <td width="90%"><xsl:number value="position()" format="1" /> - <xsl:value-of select="TRACKTITLE"/></td>...
5
by: David Sobey | last post by:
Hi Sorry bout this basic prob. Got a file called file.obj. tryna read the first line from it as a string and print it to the screen. getting errors: #include "stdafx.h" #include <stdio.h>...
2
by: Dishan Fernando | last post by:
Hi my prob is like this.. ----------------------------- create table ax( i int , j int ) create table ay( i int ,
15
by: Raj | last post by:
Hello all: We have a table with about 2400 cells. Our requirement is to highlight the cells in the table whose data has changed, every 5 seconds. Our script behaves relatively ok in Firefox, but...
6
by: skubik | last post by:
Hi everyone. I'm attempting to write a Javascript that will create a form within a brand-new document in a specific frame of a frameset. The problem is that I can create the form and input...
6
by: Mike | last post by:
Hi, I have variable strText, with value "Hello World" I see this value at Watch window. Can I change this value to "World Hello" and continue work or I need to stop program , assign new value...
2
by: scott | last post by:
Hi, I followed everything this article suggests: http://support.microsoft.com/default.aspx?scid=kb;EN-US;836734 Yet I still get the following message when stepping into a SP: "Cannot...
0
Savage
by: Savage | last post by:
I'm making for fun a simple program which format a input file.Input file sustain of person name,lastname and date of birth.Output file si supposed to be forammted as following: NAME ...
2
by: mnacw | last post by:
Can anybody help me to resolve this prob. i have installed Visual Studio 2005 Professional edition. I am working in VB.Net. When I tried to connect to database it is connected but when i make some...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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
Oralloy
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,...
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...

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.