Skip to content

Instantly share code, notes, and snippets.

@roktas
Forked from ecylmz/tersle.c
Created November 19, 2011 22:55
Show Gist options
  • Save roktas/1379491 to your computer and use it in GitHub Desktop.
Save roktas/1379491 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BUFLEN 512
char *
tersle(const char *dizgi)
{
int i, uzunluk;
char *ters_dizgi;
uzunluk = strlen(dizgi);
ters_dizgi = (char *) malloc(uzunluk + 1); /* +1 nul için */
for (i = uzunluk; i >= 0; i--)
ters_dizgi[uzunluk - i - 1] = dizgi[i];
return ters_dizgi;
}
int
main(void)
{
char *dizgi, *ters;
dizgi = (char *) malloc(BUFLEN);
printf("Dizgiyi Girin: ");
scanf("%s", dizgi);
tersi = tersle(dizgi);
printf("%s\n", tersi);
free(tersi);
free(dizgi);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment