-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ass2_2C.c
40 lines (30 loc) · 1.16 KB
/
Ass2_2C.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
============================================================================
Name : Ass2_2C.c
Author :
Version :
Copyright : Your copyright notice
Description : Hello World in C, Ansi-style
============================================================================
*/
#include <stdio.h>
#include <stdlib.h>
int main(void) {
/*
* OUTPUT:C from 2braces.com
*/
char *ptr; //creates character type pointer
char string[] = "learn C from 2braces.com"; //creates character array (aka a string)
ptr = string; /* the value of string IS the address of where the string starts.
* This stores string array's address into ptr.
* ptr now points to the start of the array, which is the first elemnt 'l'
*/
ptr += 6; /* adds 6 to current address stored within ptr
* character addresses go up by 1 Byte
* Therefore, ptr moves up 6 Bytes
* ptr initially points to first element
* the ptr should now point at the 7th element of the string, which is 'C'
*/
printf("%s",ptr); // Prints string starting from where ptr points to ('C') and stops when it finds a '\0' character at end of string
return 0;
}