C Codes
Beginners
C on Unix
Code Snippets
Data Structures
File Operations
Games Graphics
Gnu-Linux
Hardware
Mathematics
Miscellaneous
Small Programs
Sorting
C > Miscellaneous sample source codes
Swap's each set of two lines
Swap's each set of two lines #include <stdio.h> #include <string.h> int main(void) { char line[1024]; char *ptr = NULL; int i = 0; while(fgets(line, 1024, stdin) != NULL) { i++; if(i == 1) ptr = strdup(line); if(i == 2) { printf("%s", line); printf("%s", ptr); i = 0, free(ptr), ptr = NULL; } } return 0; }
Privacy Policy
|
Link to Us
|
Links