How to find a string in an array of strings in C

  Рет қаралды 9,645

CodeVault

CodeVault

Күн бұрын

Пікірлер: 27
@MuksEmmaN
@MuksEmmaN 2 жыл бұрын
Really appreciate this video. Your way of teaching is so powerful
@pcuser80
@pcuser80 2 жыл бұрын
You can also use strcasecmp does the same as strcmp but ignores the case.
@CodeVault
@CodeVault 2 жыл бұрын
Oh cool! I didn''t even know about the strcasecmp function. Thanks! I'm still on the fence about covering non-standard functions on the channel though (same reason why I didn't use strlwr in this video) What do you think? Should I start covering all these non-standard yet popular functions?
@pcuser80
@pcuser80 2 жыл бұрын
@@CodeVault Yes Please
@aatishlanghee
@aatishlanghee 2 жыл бұрын
Hi, Thank you for this amazing video. Can you please create complete C language tutorials playlist from beginner to advance in a practical hands on way. It would be good for us to get some hands on experience on the industry based problems.
@CodeVault
@CodeVault 2 жыл бұрын
I'll look into it. Thanks for the recommendation!
@bushraw66
@bushraw66 2 жыл бұрын
Thank you so much for this video. I have a question tho, at 6:27 can't we just use else{} instead whar you wrote in line 20?
@CodeVault
@CodeVault 2 жыл бұрын
Else for the if in the for loop you mean?
@bushraw66
@bushraw66 2 жыл бұрын
@@CodeVault yes , instead of writing that i>=3 does it work with just an else ?
@CodeVault
@CodeVault 2 жыл бұрын
Not really, since the message would be printed for every element that is not equal to the one you're searching
@NoNameAtAll2
@NoNameAtAll2 2 жыл бұрын
can you repeat please the need for `input[strlen(input)-1]=0` line? since there is already a null character, why overwrite last input char with 2nd one?
@0llie_K
@0llie_K 2 жыл бұрын
A new line character: ' ' is read as the last input char when the return key is pressed, In this instance it is not wanted and is therefore removed by replacing it with a null terminator.
@CodeVault
@CodeVault 2 жыл бұрын
Take a look at the video I pointed to: code-vault.net/lesson/yxllgxvfmb:1603733521595 It explains this and why we use fgets instead of scanf
@pcuser80
@pcuser80 2 жыл бұрын
@@CodeVault I use this always for removing end of line , works for windows and linux input[strcspn(input, " ")] = 0;
@soufianeamimi
@soufianeamimi 2 жыл бұрын
Can u explain about the oriented objects in c++
@CodeVault
@CodeVault 2 жыл бұрын
Yes! I plan on making a large series about OOP
@soufianeamimi
@soufianeamimi 2 жыл бұрын
@@CodeVault oooh that would be awsome
@kapellimestari0078
@kapellimestari0078 2 жыл бұрын
very good
@GillesHenrard
@GillesHenrard 2 жыл бұрын
Would a "do...while" loop with a flag variable not be cleaner than a full-fledged for loop with a break instruction?
@CodeVault
@CodeVault 2 жыл бұрын
A bit maybe. You'd still need to have the definition of i, increment and the condition somewhere in that loop. int i = 0; do { // ... } while (i < 3 && strcmp(arr[i], input) != 0); I could be biased but reading a for loop with a break is much easier to understand than a do...while loop that looks like this You can use whichever you feel is right for you though!
@GillesHenrard
@GillesHenrard 2 жыл бұрын
@@CodeVault I was more thinking about something like : int i = 0, notfound = 0; do { notfound = strcmp(arr[i], input); i++; } while (i < 3 && notfound); But as you said, except for memory or execution time constraints, only the dev's taste differs :)
@saurabhatre2158
@saurabhatre2158 Жыл бұрын
Sir video is helpful but I want to search( 4 ft × 15 inch ,0.9 21) as a whole string to be found can you help me please ( I want to use data structure too but it says _parameter error The current program finds only till 4 ft only 4 digits i want whole string to be searched at once with data structure please see to it and send source code to improve it
@CodeVault
@CodeVault Жыл бұрын
There are two options: You can either manually iterate over the string and check if the string is what you're searching for or, use a regex library (if you need to find any number in the string)
@saurabhatre2158
@saurabhatre2158 Жыл бұрын
@@CodeVault Sir, thanks for info But please share source code Array a={(4 ft x 15 inch, 0.93,21),(4ft x 15 inch ,0.93,21),(4ft x 12 inch),0.93,21)} Output: (4 ft x 15 inch, 0.93,21) =>2 (4ft x 12 inch),0.93,21) =>1
@k_ushagra
@k_ushagra 2 жыл бұрын
and this is how we know you favourite fruit or colour is Orange.. 😛😜
@shivagthegamer4933
@shivagthegamer4933 2 жыл бұрын
Thanks, but I want function of it
@CodeVault
@CodeVault 2 жыл бұрын
You could copy everything in a function and set the array of strings as parameter and the result as a return
How to generate random strings in C
8:16
CodeVault
Рет қаралды 4,2 М.
Arrays as function parameters in C
13:28
CodeVault
Рет қаралды 12 М.
ТВОИ РОДИТЕЛИ И ЧЕЛОВЕК ПАУК 😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 5 МЛН
Happy birthday to you by Secret Vlog
00:12
Secret Vlog
Рет қаралды 6 МЛН
Noodles Eating Challenge, So Magical! So Much Fun#Funnyfamily #Partygames #Funny
00:33
Difference between macros and constants in C
12:42
CodeVault
Рет қаралды 12 М.
This Algorithm is 1,606,240% FASTER
13:31
ThePrimeagen
Рет қаралды 852 М.
What are double pointers in C?
14:43
CodeVault
Рет қаралды 44 М.
Dynamically Allocate Memory For An Array Of Strings | C Programming Example
12:10
All Rust string types explained
22:13
Let's Get Rusty
Рет қаралды 183 М.
String In Char Array VS. Pointer To String Literal | C Programming Tutorial
9:58
Declaration vs. Definition of a variable in C
10:37
CodeVault
Рет қаралды 8 М.
you will never ask about pointers again after watching this video
8:03
C++ vs Rust: which is faster?
21:15
fasterthanlime
Рет қаралды 403 М.
How Senior Programmers ACTUALLY Write Code
13:37
Thriving Technologist
Рет қаралды 1,6 МЛН
ТВОИ РОДИТЕЛИ И ЧЕЛОВЕК ПАУК 😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 5 МЛН