Using only pointers: declare an array of signed integers and assing it a size of 50 integers.
Same as the last exercise but also assign positions 5, 6, and 8, and then print them.
[spoiler]
Code: Select all
#include <stdio.h>
int main()
{
int array1[50];
array1[4] = 8;
array1[5] = 20;
array1[7] = 30;
printf("%d, %d, %d\n", array1[4], array1[5], array1[7]);
return 0;
}
[/spoiler]
Using only pointers: given a random string, print from the 5th character onwards.
[spoiler]
Code: Select all
#include <stdio.h>
#include <string.h>
int main()
{
char* s1 = "Random string.";
char* s2 = s1 + 4;
printf("%s\n", s2);
return 0;
}
[/spoiler]
Given 2 strings of length 5, encrypt the first one using the second one using an XOR operation.
I'm having a hard time with this one. The only way I can think to do it would be: to get the ASCII values of both strings, then convert them to binary, and then do the XOR opperation. This seems beyond what we know though, so I'm guessing I just am thinking about it wrong.