[ create a new paste ] login | about

Link: http://codepad.org/4C7MVTqs    [ raw code | output | fork ]

C, pasted on Jun 16:
#include <stdio.h>
#include <string.h>

int main ( int argc, char *argv[] ){

   char a[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m',
                 'n','o','p','q','r','s','t','u','v','w','x','y','z'};
   char b[] = "abcdefghijklmnopqrstuvwxyz";
   char str1[26], str2[26], str3[26], str4[26];


 /*copy first 7 characters to str1 */
   strncpy(str1, a, 7);
   str1[7] = '\0';
   puts(str1);
/*from 10th characters, copy 7 characters to str2 */
   strncpy(str2, &a[9], 7);
   str2[7] = '\0';
   puts(str2);
/*from 10th characters, copy 7 characters to str3 */
   strncpy(str3, a+9, 7);
   str3[7] = '\0';
   puts(str3);
/*from 3rd characters, copy 7 characters to str4 */
   strncpy(str4, &a+3, 7);
   str4[7] = '\0';
   puts(str4);

   return 0;
}


Output:
1
2
3
4
abcdefg
jklmnop
jklmnop
,���


Create a new paste based on this one


Comments: