I hope it's obvious that I'm trying to make a comparison with the codes in the opening post.
We were storing the values from "array" into "pointer_array". Pointer_array is the one doing the...
Type: Posts; User: Valour549
I hope it's obvious that I'm trying to make a comparison with the codes in the opening post.
We were storing the values from "array" into "pointer_array". Pointer_array is the one doing the...
I understand everything that you said. Including how version 1 and version 3 are fundamentally different.
Still, questions remain.
1) For version 3, all we did was give pointer_array the...
Version 2
You're wrong about this. If you try version 2 and use %p in the printf (instead of %d), it certainly gives you the addresses of 30, 40, 50 instead of those values themselves. I...
Why then does this example declare char c instead of int c?
So it's safe to conclude that outside of EOF conditions, declaring the variable as int or char makes no difference at all, but since...
No, I fully noticed the semicolon. I understood that it's a while loop with no body at all.
The very strange thing is that while we usually put an evaluation as the condition
while (ch = !=...
While we are on the topic of getchar(), it allegedly returns an int value. Yet:
int x;
int main()
{
x=getchar(); // enter 3
printf("%d\n",x); // prints out 51 instead
}
This still doesn't explain my third question though.
So, let's pretend there is currently a newline in the buffer. The code then proceeds to
int ch = 0;
while ((ch = getchar()) != '\n' && ch...
I have looked up what getchar() does, which says it takes a single character input from the keyboard and returns the int value of it. It also does not read white spaces.
With that in mind, I still...
For version 2
1) So firstly I have stored integers where addresses should've been stored, which the compiler allows because the way actual addresses look (eg/ 28ff10), as compared to integers, are...
All three codes seem to work just fine, are any of them technically incorrect? I've read so much on arrays and pointers but at this stage I'm getting more and more confused!
I'd greatly...
Oh nevermind I figured it out xD
This is a program which replaces a certain word in a string, which I found here.
But when I'm playing around with it, I found that it fails to replace anything which is followed by a full stop....
#include <stdio.h>
#include <stdlib.h>
int main()
{
char str[1];
fgets(str, 100, stdin); //inputs hello
printf("%s", str); //outputs hello
Suppose
int a;
scanf("%d", &a); // input int 65
printf("%c", a); // outputs char A (char of the ASCII int 65)
This shows an int variable can be outputted as its corresponding char.