whats wrong with the following code??

int j[100] = {0};
    int i = 0;
    for ( ; i < 10; i++ ) {
        puts( j[i]);
    }

it keeps giving the warning

warning: passing argument 1 of ‘puts’ makes pointer from integer without a cast

And when its ran it gives a segmentation fault....any ideas?

puts is used for printing strings, not integers. Change puts( j[i]); to printf("%d\n", j[i]); and it should work better.

Member Avatar for GreenDay2001

If you just want to print single character, you could also use putchar()

>If you just want to print single character, you could also use putchar()
I had to look back at the original code to make sure I didn't make a mistake, but the array is still an array of integers and no part of the OP's post suggests that he wants to print a single character.

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.