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 a C bug

Help with a C bug

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 Posts 3 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 code here that is supposed to swap bytes in a word. For some reason it has a bug in it in the ByteSwap2 function or the ByteSwap_c function. It's getting very frustrating and time is running out. Can anyone help me..? The main is on the bottom of the code. Thanks. B

    void ByteSwap2_c(int n, short *a)
    {

    int i;

    for (i=0; i

    #include "stdio.h"

    void ByteSwap2_c(int n, short int *a);
    void ByteSwap2_asm(int n, short int *a);

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

    A D 2 Replies Last reply
    0
    • S Sirrius

      I have some code here that is supposed to swap bytes in a word. For some reason it has a bug in it in the ByteSwap2 function or the ByteSwap_c function. It's getting very frustrating and time is running out. Can anyone help me..? The main is on the bottom of the code. Thanks. B

      void ByteSwap2_c(int n, short *a)
      {

      int i;

      for (i=0; i

      #include "stdio.h"

      void ByteSwap2_c(int n, short int *a);
      void ByteSwap2_asm(int n, short int *a);

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

      A Offline
      A Offline
      Anthony_Yio
      wrote on last edited by
      #2

      If you are looking for a simple byte swap. You could try

      void _swab( char *src, char *dest, int n );

      in <stdlib.h> hope this helps Sonork 100.41263:Anthony_Yio

      1 Reply Last reply
      0
      • S Sirrius

        I have some code here that is supposed to swap bytes in a word. For some reason it has a bug in it in the ByteSwap2 function or the ByteSwap_c function. It's getting very frustrating and time is running out. Can anyone help me..? The main is on the bottom of the code. Thanks. B

        void ByteSwap2_c(int n, short *a)
        {

        int i;

        for (i=0; i

        #include "stdio.h"

        void ByteSwap2_c(int n, short int *a);
        void ByteSwap2_asm(int n, short int *a);

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

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Sirrius wrote: For some reason it has a bug...Can anyone help me..? While you'll get great advice here (assuming you ask the right question), folks are not too fond of bug hunts. What exactly is the problem? What are you trying to do? Are there compiler/linker errors? Have you single-stepped through the code to see what is happening at run-time?


        Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

        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