#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Ай бұрын
So direct and to the point, yet very instructional. You're the best bro.
@alameensaleem4158 Жыл бұрын
you are so underated
@asdasd-fk4qrАй бұрын
fr
@QuimChaos2 жыл бұрын
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; }
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 Жыл бұрын
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-Chess9 ай бұрын
Thank You bro, I Wasted one hour on this.
@kennya514 ай бұрын
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.892311 ай бұрын
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Ай бұрын
Nice video
@amkhrjee9 ай бұрын
This tut was goated no cap
@Ava-x9z3n3 ай бұрын
Thx so much for the quality c content!
@koushik-ru1zb6 ай бұрын
superrrr bro keep doijng
@Dbsmart1825 ай бұрын
Who are here before exam 😂😂
@HaamidFarhaan5 ай бұрын
Ktu?
@ProGram-nt9dc5 ай бұрын
I'm here but not before exam .
@Aff-v9o3 ай бұрын
before carreer in 22's 😅
@abirdavid504111 күн бұрын
Mee, my exam starts within a 30 minutes😢
@Dbsmart18211 күн бұрын
@@abirdavid5041 all the best
@toxiclucien81683 жыл бұрын
first comment here.....and im already a big fan of your channel ty for sharing useful information
@SpicaSuzuki3 жыл бұрын
2nd comment
@toxiclucien81683 жыл бұрын
@@SpicaSuzuki which language you are learning?
@SpicaSuzuki3 жыл бұрын
@@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?
@toxiclucien81683 жыл бұрын
@@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
@toxiclucien81683 жыл бұрын
@@SpicaSuzuki he's a great KZbinr...quite underrated
@Mmaxum Жыл бұрын
Thanks Coo Code, very cool
@nonamedelete91322 жыл бұрын
How can strcat() make string1 bigger without malloc? And I thought that a string created using [] is constant.
@kurisey80202 жыл бұрын
What does case sensitivity mean?
@akeem31272 жыл бұрын
Upper vs upper, if the first was a variable and you try to print with a second it would give and error
@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 Жыл бұрын
ask chat gpt questions like this thats what im doing when my code doesnt work and idk why
@delright6829 Жыл бұрын
@@farisraid7588 thats what i did in the end but thanks for the tip
@muchkoniabouttown69974 ай бұрын
Holy crap thanks bro!
@tejusc15682 жыл бұрын
Sir, strupr and strlwr both these functions aren't working even after including string header file. How to fix it
@trungdu93542 жыл бұрын
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 Жыл бұрын
Thank you ❤️
@mohammedisarezwani Жыл бұрын
how can we remember all these functions ?
@Mr.noname_ Жыл бұрын
by taking notes my dear haha
@zraie245511 ай бұрын
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.
@yamilaxus2 жыл бұрын
AWESOME!
@hamidabduljaabbar8419 Жыл бұрын
anyone knows why the result of my strcat(string1, string2) is BroCdee? im using linux mint distro
@KartikSharma-ik1wv Жыл бұрын
same here bro. did you find any solution
@jerileiconcepcion38662 жыл бұрын
most of these functions aren't working on my mac. any idea how to fix this?
@_____Shadow_____2 жыл бұрын
Did you use the library?
@tituskace55662 жыл бұрын
@@_____Shadow_____ yes, i did. still, it didn't work.
@bower199422 жыл бұрын
it would help if you share which error did you get when you tried to run em
@collin77762 жыл бұрын
@@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 Жыл бұрын
Broo😢 I came for string token where that at😭😭
@dvarshanidze8 ай бұрын
CooCode
@LunarProjectND4 ай бұрын
bro code u didn't cover strlen function
@RedR-r2j3 ай бұрын
these functions are not working in mac os
@junaiid0104 Жыл бұрын
hello sir the strings functions are not working on my MacBook Pro ! what do I do ?? please help me out !!!!