# 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?

Recommended Answers

All 4 Replies

So what seems to be wrong? We aren't psychic...

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

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....

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 &.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.