C string functions 🔠

  Рет қаралды 71,785

Bro Code

Bro Code

Күн бұрын

Пікірлер: 63
@BroCodez
@BroCodez 3 жыл бұрын
#include #include int main(){ char string1[] = "Bro"; char string2[] = "Code"; strlwr(string1); // converts a string to lowercase //strupr(string1); // converts a string to uppercase //strcat(string1, string2); // appends string2 to end of string1 //strncat(string1, string2, 1); // appends n characters from string2 to string1 //strcpy(string1, string2); // copy string2 to string1 //strncpy(string1, string2, 2); // copy n characters of string2 to string1 //strset(string1, '?'); //sets all characters of a string to a given character //strnset(string1, 'x', 1); //sets first n characters of a string to a given character //strrev(string1); //reverses a string //int result = strlen(string1); // returns string length as int //int result = strcmp(string1, string2); // string compare all characters //int result = strncmp(string1, string2, 1); // string compare n characters //int result = strcmpi(string1, string1); // string compare all (ignore case) //int result = strnicmp(string1, string1, 1); // string compare n characters (ignore case) printf("%s", string1); /* if(result == 0) { printf("These strings are the same"); } else { printf("These strings are not the same"); } */ return 0; }
@mrbruce4498
@mrbruce4498 Ай бұрын
So direct and to the point, yet very instructional. You're the best bro.
@alameensaleem4158
@alameensaleem4158 Жыл бұрын
you are so underated
@asdasd-fk4qr
@asdasd-fk4qr Ай бұрын
fr
@QuimChaos
@QuimChaos 2 жыл бұрын
strlwr(string) and strupr(string) don't exist in standard c library string.h. you have to have a little fun and create it yourself, by using a loop that calculates the correspondent lower/uppercase char in the ASCII table and replacing it, or usinc ctype.h and tolower()/toupper() functions to convert cases. the same for strset(), strnset(), strrev(), strcmpi() and strnicmp() not defining the size of the strings results in stack overflow/stack smashing and unexpected behaviour. Examples for string to lowercase/uppercase (this doesn't accept string literals as arguments): #include char* stringToUpper(char * string){ int i = 0; while (string[i] != '\0'){ string[i] = (char)toupper(string[i]); i++; } return string; } char* stringToLower(char * string){ int i = 0; while (string[i] != '\0'){ string[i] = (char)tolower(string[i]); i++; } return string; }
@QuimChaos
@QuimChaos 2 жыл бұрын
better, much better: #include #include void stringToUpper(char * string){ while (*string != '\0'){ *string = (char)toupper(*string); string++; } } void stringToLower(char * string){ while (*string != '\0'){ *string = (char)tolower(*string); string++; } } int main() { char string1[50] = "Hello"; stringToUpper(string1); printf("To upper %s ", string1); stringToLower(string1); printf("To lower %s ", string1); return 0; }
@gustaw6000
@gustaw6000 2 жыл бұрын
I cannot find those two functions in IBM documentary for C standard libraries, although it works in Visual Studio Code. Maybe they added those function recently?
@brisauce6944
@brisauce6944 Жыл бұрын
Thank you for clarifying this! It's confusing to a new programmer like me when I see things like "implicit declaration of is not valid in c99", despite it being mentioned in a tutorial video. You're a sanity saver man!
@Birendra-Chess
@Birendra-Chess 9 ай бұрын
Thank You bro, I Wasted one hour on this.
@kennya51
@kennya51 4 ай бұрын
The in MacOS/Linux different of that of the Windows . strlwr(), strupr() are "non-standard", so they only exist in the Windows one, which BroCode is using.
@xetycm.8923
@xetycm.8923 11 ай бұрын
I was to so some of the functions (like strlwr, strcmpi, and etc) but for some reason they didn't exist in the string.h library (it kept saying the function doesn't exist). some people suggest that I make these functions myself using other libraries; but is there a way to fix the issue i'm having?
@buzzbuzz20xx
@buzzbuzz20xx Ай бұрын
Nice video
@amkhrjee
@amkhrjee 9 ай бұрын
This tut was goated no cap
@Ava-x9z3n
@Ava-x9z3n 3 ай бұрын
Thx so much for the quality c content!
@koushik-ru1zb
@koushik-ru1zb 6 ай бұрын
superrrr bro keep doijng
@Dbsmart182
@Dbsmart182 5 ай бұрын
Who are here before exam 😂😂
@HaamidFarhaan
@HaamidFarhaan 5 ай бұрын
Ktu?
@ProGram-nt9dc
@ProGram-nt9dc 5 ай бұрын
I'm here but not before exam .
@Aff-v9o
@Aff-v9o 3 ай бұрын
before carreer in 22's 😅
@abirdavid5041
@abirdavid5041 11 күн бұрын
Mee, my exam starts within a 30 minutes😢
@Dbsmart182
@Dbsmart182 11 күн бұрын
@@abirdavid5041 all the best
@toxiclucien8168
@toxiclucien8168 3 жыл бұрын
first comment here.....and im already a big fan of your channel ty for sharing useful information
@SpicaSuzuki
@SpicaSuzuki 3 жыл бұрын
2nd comment
@toxiclucien8168
@toxiclucien8168 3 жыл бұрын
@@SpicaSuzuki which language you are learning?
@SpicaSuzuki
@SpicaSuzuki 3 жыл бұрын
@@toxiclucien8168 c is my first language (except shell. idk shell that much but i use linux). i'm learning c rn. i came here to copy paste the code. You?
@toxiclucien8168
@toxiclucien8168 3 жыл бұрын
@@SpicaSuzuki I'm currently learning C in my university so fam here to copy the code .....I have completed the whole video and now I can create any program which I'm told to....(except for the maths one coz I need to revise my maths formula for it)...but other than that I also made 3 games with Brocode help
@toxiclucien8168
@toxiclucien8168 3 жыл бұрын
@@SpicaSuzuki he's a great KZbinr...quite underrated
@Mmaxum
@Mmaxum Жыл бұрын
Thanks Coo Code, very cool
@nonamedelete9132
@nonamedelete9132 2 жыл бұрын
How can strcat() make string1 bigger without malloc? And I thought that a string created using [] is constant.
@kurisey8020
@kurisey8020 2 жыл бұрын
What does case sensitivity mean?
@akeem3127
@akeem3127 2 жыл бұрын
Upper vs upper, if the first was a variable and you try to print with a second it would give and error
@delright6829
@delright6829 Жыл бұрын
im little bit confused everything here works besides strset,strnset and strrev vs isnt recognizing them. i believe theyre not included in string.h and stdio.h is there a fix to it ? im writing my exam next week and were only allowed to use libraries we got shown example: bool etc aint allowed.
@farisraid7588
@farisraid7588 Жыл бұрын
ask chat gpt questions like this thats what im doing when my code doesnt work and idk why
@delright6829
@delright6829 Жыл бұрын
@@farisraid7588 thats what i did in the end but thanks for the tip
@muchkoniabouttown6997
@muchkoniabouttown6997 4 ай бұрын
Holy crap thanks bro!
@tejusc1568
@tejusc1568 2 жыл бұрын
Sir, strupr and strlwr both these functions aren't working even after including string header file. How to fix it
@trungdu9354
@trungdu9354 2 жыл бұрын
Looked up source of didn't see them function in there so to fix had to manually write a internal code inside code, or could make my own newfunction.c file and import it there since going use it often (Put these 2 codes above your int main() not inside it) //Beginner Version strlwr() char * strlwr(char * s){ char *t = s; if (!s){ return 0; } int i = 0; while ( *t != '\0' ){ if (*t >= 'A' && *t = 'a' && *t
@haseebkahn4811
@haseebkahn4811 Жыл бұрын
Thank you ❤️
@mohammedisarezwani
@mohammedisarezwani Жыл бұрын
how can we remember all these functions ?
@Mr.noname_
@Mr.noname_ Жыл бұрын
by taking notes my dear haha
@zraie2455
@zraie2455 11 ай бұрын
You don't need to remember all these functions! You can pretty much write code using your knowledge so far that accomplishes what these functions do. Knowing these functions just makes it easier for you to write code as you won't have to write new functions in your code with a specific purpose if you remember that there's a library which already does that. I.e. you won't have to create an pow(x, y) function in your program if you remember that math.h has a library with a similar function.
@yamilaxus
@yamilaxus 2 жыл бұрын
AWESOME!
@hamidabduljaabbar8419
@hamidabduljaabbar8419 Жыл бұрын
anyone knows why the result of my strcat(string1, string2) is BroCdee? im using linux mint distro
@KartikSharma-ik1wv
@KartikSharma-ik1wv Жыл бұрын
same here bro. did you find any solution
@jerileiconcepcion3866
@jerileiconcepcion3866 2 жыл бұрын
most of these functions aren't working on my mac. any idea how to fix this?
@_____Shadow_____
@_____Shadow_____ 2 жыл бұрын
Did you use the library?
@tituskace5566
@tituskace5566 2 жыл бұрын
@@_____Shadow_____ yes, i did. still, it didn't work.
@bower19942
@bower19942 2 жыл бұрын
it would help if you share which error did you get when you tried to run em
@collin7776
@collin7776 2 жыл бұрын
@@tituskace5566 So the strlwr and strupr along with some other functions listed in this video are part of the Microsoft implementation of C. Mac/linux/unix have to use different functions to alter strings. You can either use the ctype.h or code the functions yourself.
@unikneupane01
@unikneupane01 Жыл бұрын
Broo😢 I came for string token where that at😭😭
@dvarshanidze
@dvarshanidze 8 ай бұрын
CooCode
@LunarProjectND
@LunarProjectND 4 ай бұрын
bro code u didn't cover strlen function
@RedR-r2j
@RedR-r2j 3 ай бұрын
these functions are not working in mac os
@junaiid0104
@junaiid0104 Жыл бұрын
hello sir the strings functions are not working on my MacBook Pro ! what do I do ?? please help me out !!!!
@naveenkumar1853
@naveenkumar1853 Жыл бұрын
😢
C for loops 🔁
3:23
Bro Code
Рет қаралды 163 М.
C pointers explained👉
8:04
Bro Code
Рет қаралды 198 М.
УДИВИЛ ВСЕХ СВОИМ УХОДОМ!😳 #shorts
00:49
How many people are in the changing room? #devil #lilith #funny #shorts
00:39
Turn Off the Vacum And Sit Back and Laugh 🤣
00:34
SKITSFUL
Рет қаралды 8 МЛН
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 28 МЛН
String In Char Array VS. Pointer To String Literal | C Programming Tutorial
9:58
C-string functions: strlen, strcpy, strcat, strncpy, strncat, strcmp, strstr
10:10
#22  C String Functions | C Programming For Beginners
9:40
Programiz
Рет қаралды 87 М.
C function prototypes 🤖
4:37
Bro Code
Рет қаралды 56 М.
strcpy() and strncpy() functions | C Programming Tutorial
8:15
Portfolio Courses
Рет қаралды 40 М.
2 Years of C++ Programming
8:20
Zyger
Рет қаралды 7 М.
All Rust string types explained
22:13
Let's Get Rusty
Рет қаралды 184 М.
Programming Is Cooked
9:30
ThePrimeTime
Рет қаралды 305 М.
you will never ask about pointers again after watching this video
8:03
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 829 М.
УДИВИЛ ВСЕХ СВОИМ УХОДОМ!😳 #shorts
00:49