Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- char* text1 = "This is a string.";
- char* text2 = "Yet another thing.";
- int list1[20];
- int list2[20];
- int count = 0;
- void printlist(const int* lst){
- printf("ASCII codes and corresponding characters.\n");
- while(*lst != 0){
- printf("0x%03X '%c' ", *lst, (char)*lst);
- lst++;
- }
- printf("\n");
- }
- void endian_proof(const char* c){
- printf("\nEndian experiment: 0x%02x,0x%02x,0x%02x,0x%02x\n",
- (int)*c,(int)*(c+1), (int)*(c+2), (int)*(c+3));
- }
- void copycodes(char* text,int* list, int* count)
- {
- while (*text)
- {
- *list = *text;
- list ++;
- text ++;
- *count += 1;
- }
- } // 0010 0011
- void work()
- {
- copycodes(text1, list1, &count);
- copycodes(text2, list2, &count);
- }
- int main(void){
- work();
- printf("\nlist1: ");
- printlist(list1);
- printf("\nlist2: ");
- printlist(list2);
- printf("\nCount = %d\n", count);
- endian_proof((char*) &count);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement