473,385 Members | 2,180 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.

What does "undeclared identifier" mean?

I thought it meant that I hadn't declared a variable but I have.

Expand|Select|Wrap|Line Numbers
  1. int DoubleNumbers(int seq[], int *digitNum)
  2. {
  3.     int i, j;
  4.  
  5.     for (i = 0; i = 9; i++)
  6.         for (j = i + 1; j = 9; j++)
  7.             if (seq[i] == seq[j]){
  8.                 *digitNum = j;
  9.                 return 1;
  10.             }
  11.     return 0;
  12. }
  13.  
An error message comes up and says that both i and j are "undeclared identifiers". Can anyone help me?
Oct 11 '06 #1
6 42488
Banfa
9,065 Expert Mod 8TB
That code compiles fine for me, no problems, it must be a different bit of your code causeing the error.
Oct 11 '06 #2
D_C
293 100+
Expand|Select|Wrap|Line Numbers
  1. for (i = 0; i = 9; i++)
should probably changed to
Expand|Select|Wrap|Line Numbers
  1. for (i = 0; i != 9; i++)
or
Expand|Select|Wrap|Line Numbers
  1. for (i = 0; i < 10; i++)
Similarly for j.
Oct 12 '06 #3
u'r code , i thing it should be like that
for(i=0;i<10;i++)
Oct 12 '06 #4
Banfa
9,065 Expert Mod 8TB
I thought it meant that I hadn't declared a variable but I have.
It does which is why I don't think this problem is in this section of code.

However take note of what everyone else has said or your code will enter an infinite loop.
Oct 12 '06 #5
euxon
1
Remember scope for "for"-loops.
Expand|Select|Wrap|Line Numbers
  1. int DoubleNumbers(int seq[], int *digitNum) 
  2.     int i, j; 
  3.  
  4.     for (i = 0; i = 9; i++){ 
  5.         for (j = i + 1; j = 9; j++){ 
  6.             if (seq[i] == seq[j]){ 
  7.                 *digitNum = j; 
  8.                 return 1; 
  9.             }
  10.          }
  11.     } 
  12.     return 0; 
  13.  
Feb 22 '13 #6
Banfa
9,065 Expert Mod 8TB
While adding braces in this manor is good practice in this particular instance adding those braces does not actually change the codes functionality.
Feb 22 '13 #7

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

Similar topics

37
by: Jon Perez | last post by:
I saw this code snippet: sock.listen(20) for _ in range(20): newsock, client_addr = sock.accept() print "Client connected:", client_addr data = "" why use _ for this example? Is there any...
2
by: Jacek Dziedzic | last post by:
Is it valid to use a "using namespace foo" (as opposed to using foo::bar which I'm sure is legal) within a class declaration? My compiler rejects it, but I've been told it's valid. Can anyone...
6
by: craigbeanhead | last post by:
Hi, I'm teaching myself C from K&R2. I've come across something that I really don't understand. When I try to compile the following code (in VC++7), I get an "undeclared identifier" error. When...
1
by: vishal | last post by:
What does #line 182 parser.y mean in a C program?
4
by: Stephen Corey | last post by:
I've got 2 classes in 2 seperate header files, but within the same namespace. If I use a line like: // This code is inside Class2's header file Class1 *newitem = new Class1(param1, param2); ...
5
by: coste068 | last post by:
I am using visual studio and can't seem to figure out why I keep getting this error when I compile. Any suggestions? Here is the relevant code: #include <iostream> int main() { ..........
3
by: harshadanarvekar | last post by:
Hi Everyone, Here is a part of javascript code that works well in FF2 but shows above error in IE6 and error "missing name after . operator" in NS8 function PopUp(idf,stepX,stepY,speed){
1
by: mikr | last post by:
I'm new to jquery, and hoping it will make my client side coding more friendly (particularly with regards to ie). As is usually the case, I've got some code that works nicely in ff, but kicks out...
2
by: Surgey | last post by:
Hi, I have the following WINAPI event, int WINAPI WlxLoggedOnSAS(PVOID pWlxContext,DWORD dwSasType,PVOID pReserved) { if (dwSasType == WLX_SAS_TYPE_CTRL_ALT_DEL) { // Add additional code of...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.