Correcting a spelling mistake (#19845)
* Correcting a spelling mistake * Formatting and adding missing code * Removing extra code * Update index.md
This commit is contained in:
committed by
Tracey Bushman
parent
d14ec72fb8
commit
b6ad5afb70
@@ -118,12 +118,12 @@ void copy_string(char [] first_string, char [] second_string)
|
||||
```C
|
||||
strcat(first, second);
|
||||
```
|
||||
Here is an example of manual implementation of fuction strcat:
|
||||
Here is an example of manual implementation of function strcat:
|
||||
|
||||
void string_concatenate(char [] s1, char [] s2)
|
||||
{
|
||||
int i = strlen(s1), j;
|
||||
for(int j = 0; s2[j]; j++, i += 1)
|
||||
for(j = 0; s2[j]; j++, i += 1)
|
||||
{
|
||||
s1[i] = s2[j];
|
||||
}
|
||||
@@ -140,7 +140,7 @@ int string_length(char [] string)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(int i = 0; string[i]; i++);
|
||||
for(i = 0; string[i]; i++);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
@@ -53,7 +53,7 @@ point img_dim = { .y = 480, .x = 640 };
|
||||
```
|
||||
|
||||
## Unions vs Structures
|
||||
Unions are declared in the same was as structs, but are different because only one item within the union can be used at any time.
|
||||
Unions are declared in the same way as structs, but are different because only one item within the union can be used at any time.
|
||||
|
||||
```C
|
||||
typedef union{
|
||||
@@ -83,6 +83,6 @@ typedef union{
|
||||
```
|
||||
|
||||
## A few more tricks
|
||||
* When you create a pointer to a structure using the `&` operator you can use the special `->` infix operator to deference it. This is very used for example when working with linked lists in C
|
||||
* When you create a pointer to a structure using the `&` operator you can use the special `->` infix operator to deference it. This is used for example when working with linked lists in C
|
||||
* The new defined type can be used just as other basic types for almost everything. Try for example to create an array of type `student` and see how it works.
|
||||
* Structs can be copied or assigned but you can not compare them!
|
||||
|
Reference in New Issue
Block a user