0
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include <conio.h>

typedef struct{
        int a[99];
        }number;

const int max = 99;  


int main  () {   
    number array;
    int j;
    int count = 0;    
    
    for ( j= 1; j <=max; j++ ){
        count = count +1 ;
        array.a[j] = count;
       }
          
        printf("%d\n",&array.a[10]);
       
       
        getch ();
        
        }

aim is to just insert 1 into position 1 , 2 in position 2 of array etc and print what digit will be in array 10, can someone help me?

Edited by cyberguy007: n/a

4
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by Dave Sinkula
0

We aren't psychic...

I am, sort of. At least I have a crystal ball. And it tells me about the problems:
- writing to invalid memory
- printing an address as "%d"
- #including conio.h

0

its printing some weird number thus i'm not sure if the prob lies in inserting correctly ie 1 to position 1 etc or the prob lies in the print....

0

An array a[99] has 99 elements, indexed from a[0] to a[98].
You are trying to index this array from a[1] to a[99].

In your lone printf, drop the &.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.