035 - STM32F1 USART Build C functions: String search, concatenate, integer 2 string, string to int

preview_player
Показать описание
Welcome to the WeeW - Stack

Welcome to this new video for the STM32F1 microcontroller, where the code is from scratch.

This video has the following topic of Building c funtions to:

1- get the length of a string

2- find a string inside a string

3- finding an exact string match

4- Concatenate 2 strings

5- Convert integer to string

6- Conver string to unsigned interger
Рекомендации по теме
Комментарии
Автор

Best tutorial ever made on this topic "STM32F1 and Keil c". waiting for your next tutorials.

maazizpeaceinstituteoftech
Автор

Hi Weew, excellent tutorial!
I revised find_str function below :)

// Find a string on a string
// str1 is the string to find in str2
unsigned int find_str(char str1[], char str2[])
{

unsigned int position = 0; // Array pointer for the two strings
unsigned int offset = 0; // Offset index for str2
unsigned int char_match = 0; // Character match counter

unsigned int str1_len =

// While there are exact number of str1 characters to compare starting from the offset position of str2
while(str2[offset + (str1_len-1)] != '\0')
{
// Compare characters of str1 in str2
for(position=0; position<str1_len; position++)
{
if(str1[position] == str2[offset+position])
{

== str1_len-1)

String match found
1;

}else
{

}
}
char_match = 0;
// Increment offset
offset++;
}
// No string match
return 0;
}

hhunter
Автор

Why "str2[i + STRlen-1] != '\0' " condition is needed in the find_str function?

marxl
Автор

Strange, but in my case find_str func working only without STRlen+1. Thoughting about errors i copied yr function's code from github, nevertheless, code's working without +1 :)

НикитаЛеонтьев-дж
welcome to shbcf.ru