Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Help with some C

Help with some C

Scheduled Pinned Locked Moved C / C++ / MFC
performancehelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sirrius
    wrote on last edited by
    #1

    I have some C code here, my teachers, that I'm trying to rifle through and figure out. I am confused on on line of it: The second line down is

    *b = (int*) malloc ( n * sizeof(int));

    does this mean a integer pointer that point to a memory location that is 4 times the size of an integer? Which would be then 16 bytes. So a int pointer that points to 16 bytes of vacant memory. Am I right, close or way off. Please help. the code below is what it is out of. Thanks for your help.

    #include "stdio.h"

    void ByteSwap4_c(int n, int *a);
    void ByteSwap4_asm(int n, int *a);

    void ByteSwap4(int n, int *a)
    {
    int i;
    int *b = (int*) malloc ( n * sizeof(int));
    for (i=0; i

    void ByteSwap4_c(int n, int *a)
    {
    int i;
    for (i=0; i

    M 1 Reply Last reply
    0
    • S Sirrius

      I have some C code here, my teachers, that I'm trying to rifle through and figure out. I am confused on on line of it: The second line down is

      *b = (int*) malloc ( n * sizeof(int));

      does this mean a integer pointer that point to a memory location that is 4 times the size of an integer? Which would be then 16 bytes. So a int pointer that points to 16 bytes of vacant memory. Am I right, close or way off. Please help. the code below is what it is out of. Thanks for your help.

      #include "stdio.h"

      void ByteSwap4_c(int n, int *a);
      void ByteSwap4_asm(int n, int *a);

      void ByteSwap4(int n, int *a)
      {
      int i;
      int *b = (int*) malloc ( n * sizeof(int));
      for (i=0; i

      void ByteSwap4_c(int n, int *a)
      {
      int i;
      for (i=0; i

      M Offline
      M Offline
      markkuk
      wrote on last edited by
      #2

      The malloc() call allocates space for a table of n integers.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups