Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Segment Violation

Name: fsdf 2011-03-14 20:32

I cant find the last segment violation, I think its in line 26 but I dont know what it should be.

#include "stdio.h"
#include "string.h"

// function prototypes
void strrvr( char outstr[] , char instr[] );

// driver
int main()
{
char outstr[100];
char instr[100]="emordnilap";
strrvr(outstr, instr);
printf( "%s\n", outstr );
return( 0 );
}

// strrvr function
void strrvr(char strout[], char strin[])
{
int i;
int n = strlen( strin );
strout[i] = strout[n]; // copy the null string terminator
for (i = 0 ; i < n ; i-- )
strout[n-i-1] = strin[n];
}

Name: Anonymous 2011-03-15 17:06

>>37
const __attribute__((always_inline) (const)) static inline void
strrvr (const char * restrict ____i, char * restrict ____o)
  {
    size_t ____p = strlen(____i);

    for (;____p & 7;____i++,____p--)
      *(____o + ____p - 1)=*____i;

    for (; ____p; ____i+=8, ____p-= 8)
      *(uint64_t*) (____o + ____p - 8)  = __builtin_bswap64(*(uint64_t*) ____i);
  }

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List