Search:

Type: Posts; User: Valour549

Search: Search took 0.01 seconds.

  1. Replies
    14
    Views
    9,433

    I hope it's obvious that I'm trying to make a...

    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...
  2. Replies
    14
    Views
    9,433

    I understand everything that you said. Including...

    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...
  3. Replies
    14
    Views
    9,433

    Version 2 You're wrong about this. If you try...

    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...
  4. Why then does this example...

    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...
  5. No, I fully noticed the semicolon. I understood...

    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 = !=...
  6. While we are on the topic of getchar(), it...

    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
    }
  7. This still doesn't explain my third question...

    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...
  8. Using getchar() to flush newline from input buffer

    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...
  9. Replies
    14
    Views
    9,433

    For version 2 1) So firstly I have stored...

    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...
  10. Replies
    14
    Views
    9,433

    Arrays and Pointers (very confused)

    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...
  11. Replies
    2
    Views
    1,865

    Oh nevermind I figured it out xD

    Oh nevermind I figured it out xD
  12. Replies
    2
    Views
    1,865

    Why does this code fail after a full stop

    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....
  13. Replies
    2
    Views
    2,849

    Storing string using fgets into an array

    #include <stdio.h>
    #include <stdlib.h>


    int main()
    {

    char str[1];
    fgets(str, 100, stdin); //inputs hello
    printf("%s", str); //outputs hello
  14. Replies
    1
    Views
    1,243

    Regarding int char %d %c

    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.
Results 1 to 14 of 14