help needed with array

This is a discussion on help needed with array within the C Programming forums, part of the General Programming Boards category; hey guys, doin this program at slyfx, needed some help. The original code has pretty messed up, so i re ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    134

    help needed with array

    hey guys, doin this program at slyfx, needed some help. The original code has pretty messed up, so i re wrote it. It copied some numbers from a file into an array. So in the new prorgam i did that manually, but i get a strange error message...any input will be appreciated

    Code:
    #include<stdio.h>
    #include<stdlib.h>
    
    int main()
    {
        int elements[30]={56453578,20,24850,324542,85642,385,74623,0923,789,4215,769757,694156,1721,465838,54760,4564857,4050,9415,
    		72087,45843,697526,487,576478,275,443456,542345,67,8976,54356,789552};
    	
    	
    	int k=0,res=0;
    	
    
    	for(k=0;k<=29;k++)printf("%d\n",elements[k]);
    
    	for(k=0;k<=29;k++)
    	{
    		res+=(elements[k]?(elements[k]-50):69)?elements[k]:69;
    		while (res>300000)
    		{
    			res-=elements[k]?elements[k]:169;
    		}
    	}
    
    	printf("%d is the result\n",res);
    	system("PAUSE");
    	return 0;
    }

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    but i get a strange error message...any input will be appreciated
    Here's a novel ideal, how about sharing with us what error message you get?

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    134
    this is the error message
    error C2041: illegal digit '9' for base '8'

  4. #4
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,157
    Does the error message mention a line the error is on? If so, post the line number and the line itself.

    Walt

  5. #5
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    Code:
       int  elements[30]={56453578,20,24850,324542,85642,385,74623, 0923 ,789,4215,769757,694156,1721,465838,54760
    ,4564857,4050,9415,72087,45843,697526,487,576478,275,443456,542345,67,8976,54356,789552};
    A number starting with a 0 means it's an octal number (base 8). The second number is a 9 and is not part of base 8 (0..7). Remove the leading 0.

  6. #6
    Registered User
    Join Date
    Mar 2003
    Posts
    134
    thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 07-11-2008, 07:39 AM
  2. Little Array Difficulty
    By G4B3 in forum C Programming
    Replies: 16
    Last Post: 03-19-2008, 12:59 AM
  3. Modify an single passed array element
    By swgh in forum C Programming
    Replies: 3
    Last Post: 08-04-2007, 08:58 AM
  4. Array Program
    By emmx in forum C Programming
    Replies: 3
    Last Post: 08-31-2003, 12:44 AM
  5. two dimensional dynamic array?
    By ichijoji in forum C++ Programming
    Replies: 6
    Last Post: 04-14-2003, 04:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21