Skip to main content

All Questions

-1 votes
1 answer
57 views

Malloc Array, trouble printing in new function in C [duplicate]

Hi I've created an array and used malloc to store it so it could use it in a different function but now I'm running into problems with printing the array as it says: warning: format '%d' expects ...
Wolo's user avatar
  • 5
-3 votes
3 answers
3k views

Why does using the "%s" format specifier to printf an array of char output additional nonsense values after the final char in the array? [duplicate]

I stumbled upon this behavior that I am curious to understand. I mistakenly wrote the following at the end of a program to print the elements in an array of char : printf("output: %s",outputText[]); ...
zangiku's user avatar
  • 57
7 votes
4 answers
11k views

2 ways of accessing value of an array of pointers in C

The first block #include <stdio.h> const int MAX = 3; int main() { int var[] = { 10, 100, 200 }; int i, *ptr[MAX]; for (i = 0; i < MAX; i++) { ptr[i] = &var[i]; /...
Albert Gao's user avatar
  • 3,789
3 votes
4 answers
134 views

Pointers holding something other than an adress? [C]

I've been studying C for a few months at university now, but I missed a lecture about pointers, so I tried to make up for it by studying it online and I thought I got it - but something I just ...
Pumamori's user avatar
1 vote
2 answers
2k views

Array prints just zeros

I have created an array with random numbers, but when I print the array they are all 0, what is wrong here? I know that the random numbers are there, but still zeros? int superArray[SIZE]; int index, ...
Anders Bruun's user avatar
-2 votes
4 answers
192 views

What is difference between hex and char array print?

I have written following programe in c #include <stdio.h> char str[]="hello world"; unsigned char hexvalue[] = {0x01,0x02,0x03,0x04,0x05}; int main() { int i; printf("string %s \n", ...
Jayesh Bhoi's user avatar