Skip to content

Instantly share code, notes, and snippets.

@dulimarta
Last active January 29, 2016 15:34
Show Gist options
  • Save dulimarta/9070b25ad59edae6f88c to your computer and use it in GitHub Desktop.
Save dulimarta/9070b25ad59edae6f88c to your computer and use it in GitHub Desktop.
CS452 Lab01 - Sample 3
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 16
int main () {
char *data1, *data2, *tmp;
int k;
data1 = malloc (SIZE);
data2 = malloc (SIZE);
tmp = data1;
printf ("Please input your username: ");
scanf ("%s", data1);
for (k = 0; k < SIZE; k++)
data2[k] = *(tmp++);
free (data1);
printf ("data2 :%s:\n", data2);
printf ("tmp :%s:\n", tmp);
free (data2);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment