Great explanation. Would appreciate something on structs if possible, in particular use of the flexible array member (unsized last element in struct). thanks
To print integer arrays, we would normally need a loop and some variable to move through the indices, one after the other. But why isn't this the case with character arrays? Why do we just type the array variable name and everything works fine?
Succinct and to the point. Very educational. Here's a challenge, using Git to control a solo project from multiple computers. Git still seems nebulous and complex. Maybe you can show us how with no time a wasting.
That's exactly what I use git for and is the easier aspect of it. You just need 4 commands, git commit, git add, git pull, and git push. Now getting into branches, pull requests, releases, tagging, etc; that's the hard part.
Isn't the NULL byte '/0' the same as 0 or zero? I have successfully used a plain zero to terminate strings in C. Is that just a compiler specific (Boreland 4.5) exception?
@@EngineerMan Well say you want to truncate a string to 6 bytes max, in this case six ASCII characters. I just plug a zero into the str_array[6] position. That effectively chops it off. Now as I said this works with the old Boreland C compliers including 4.5. I'm not sure if this is a legal C practice? char s1[[16]; strcpy (s1, "HelloWorld"); s1[6]= 0; printf("%s",s1); result: HelloW
@andydelle4509 4 years late, but just so you know: 0 is an int, \0 is a char. They are functionally the same. So int 0 == char \0 BUT char 0 != char \0. Makes sense?
Hi Engineer Man! Thank you for posting this video and welcome to UA-cam! In your intro video you said that you like video request so here is one for you... I am trying to create a program in C to load a tab delimited text file, from any folder on my computer(in the future to be input from the user), print the text (strings, I believe) from the text document to the screen, then sort the information based upon a certain column, reprint it to the screen, and then finally save it to a new text file. Can you help me, and everyone else, by showing me how I might go about doing this? This is not for hw/class, it is a personal project. Here is what I have so far: #include #include #define N 30 int main() { char name[]; char course[]; FILE *pointer = fopen("C:\\Users\\Jesse Hight\\Desktop \\TutoringCodeFolder\SimplifiedStudentRequests", "r"); test=fscanf(pointer, "%s,%s",&name[N],&course[N]); printf("%s\t%s", name[ ],course[ ]); fclose(f); /* Idea: row 1 of array 1 (from the original file)=row 1 of array2. search array 1 for a course equal to row 1 of array 2. for( ) if(array1[i][2]==array2[1][3] array2[k][L]=array1[i][2] k++ L=3 else search array1 for new subject not equal to current/last row of array2 new subject from array1=next row of array2 */ } The original text file looks like: Jesse ES 330-01 John MA 330-01 Alexa MA 330-01 Jose FN 361-01 Dave FN 361-01 Gabriel ES 330-01 Steve FN 361-01 Parker FN 361-01 Robert FN 361-01 Caroline ES 330-01 And I would like the output to be like this, with the list sorted by common classes: Jesse ES 330-01 Caroline ES 330-01 Gabriel ES 330-01 John MA 330-01 Alexa MA 330-01 Jose FN 361-01 Dave FN 361-01 Steve FN 361-01 Parker FN 361-01 Robert FN 361-01 Thank you!
I don't know if someone will answer me: how can I save the first character of a string , for example char c; char * string; string="hello"; c=getc(string); //someone told this could work but it doesn't work Please help
@@EngineerMan thank you so much! Sorry to bother you... and what if a want to give my variable "string" any other value, do I must use scanf? char c; char *string; scanf("%s", string); c = string [0]; printf("%c", c); This would be ok?
you're saving me from a professor who can't teach so I'm gonna watch all the ads I need to I love you
in less than 6 minutes you taught me more about C and strings in C than i ever learned in a full semester on C programming. thank you, @EngineerMan!!
Thank you! Easy to understand as a beginner and straight to the point
Amazing content, great explanations. I love those short but really good comments for every code line!
Very precise an informative video .Thank you for uploading and hoping to see further more videos like this.
You can count on it!
Incredible, short and easy to understand. Thank you!
Great vids for brushing up on c before some classes, much love brother
Great explanation. Would appreciate something on structs if possible, in particular use of the flexible array member (unsized last element in struct). thanks
Will add it to pending video list!
Dude this is so trippy coming from Java, thank you!
you explained more about strings in 6 minutes than my teacher did in the whole semester...
Best explanation so far on c strings. Thanks
Nice content full of information. Thanks clearing the doubts.
Engineer bro I want to thank you so much you need to teach I mean that! I had 2 eureka moments watch this video!
This video is really good! Thank you!
Beautiful. Simple and Elegant.
thank you engineer man... Your videos help a lot !
Awesome and succinct. Thanks a ton for these.
really good introductoy video
To print integer arrays, we would normally need a loop and some variable to move through the indices, one after the other.
But why isn't this the case with character arrays? Why do we just type the array variable name and everything works fine?
Succinct and to the point. Very educational.
Here's a challenge, using Git to control a solo project from multiple computers. Git still seems nebulous and complex. Maybe you can show us how with no time a wasting.
Craig Faas I love Git! I could certainly do that.
That's exactly what I use git for and is the easier aspect of it. You just need 4 commands, git commit, git add, git pull, and git push. Now getting into branches, pull requests, releases, tagging, etc; that's the hard part.
Thanks for another helpful video! Could you possibly do one on creating different structures in C, for example a Binary Tree?
Yeah, I can definitely look at doing that!
to the point, no BS. respect.
Isn't the NULL byte '/0' the same as 0 or zero? I have successfully used a plain zero to terminate strings in C. Is that just a compiler specific (Boreland 4.5) exception?
I'm thinking so. If a 0 could be substituted in place of a null byte, how would one have a string with a 0 in it?
@@EngineerMan Well say you want to truncate a string to 6 bytes max, in this case six ASCII characters. I just plug a zero into the str_array[6] position. That effectively chops it off. Now as I said this works with the old Boreland C compliers including 4.5. I'm not sure if this is a legal C practice?
char s1[[16];
strcpy (s1, "HelloWorld");
s1[6]= 0;
printf("%s",s1);
result: HelloW
@andydelle4509 4 years late, but just so you know: 0 is an int, \0 is a char. They are functionally the same. So int 0 == char \0 BUT char 0 != char \0. Makes sense?
@@davez5201 Yes, thanks.
Hi Engineer Man! Thank you for posting this video and welcome to UA-cam! In your intro video you said that you like video request so here is one for you... I am trying to create a program in C to load a tab delimited text file, from any folder on my computer(in the future to be input from the user), print the text (strings, I believe) from the text document to the screen, then sort the information based upon a certain column, reprint it to the screen, and then finally save it to a new text file. Can you help me, and everyone else, by showing me how I might go about doing this? This is not for hw/class, it is a personal project.
Here is what I have so far:
#include
#include
#define N 30
int main()
{
char name[];
char course[];
FILE *pointer = fopen("C:\\Users\\Jesse Hight\\Desktop
\\TutoringCodeFolder\SimplifiedStudentRequests", "r");
test=fscanf(pointer, "%s,%s",&name[N],&course[N]);
printf("%s\t%s", name[ ],course[ ]);
fclose(f);
/*
Idea:
row 1 of array 1 (from the original file)=row 1 of array2.
search array 1 for a course equal to row 1 of array 2.
for( )
if(array1[i][2]==array2[1][3]
array2[k][L]=array1[i][2]
k++
L=3
else
search array1 for new subject not equal to current/last row of array2
new subject from array1=next row of array2
*/
}
The original text file looks like:
Jesse ES 330-01
John MA 330-01
Alexa MA 330-01
Jose FN 361-01
Dave FN 361-01
Gabriel ES 330-01
Steve FN 361-01
Parker FN 361-01
Robert FN 361-01
Caroline ES 330-01
And I would like the output to be like this, with the list sorted by common classes:
Jesse ES 330-01
Caroline ES 330-01
Gabriel ES 330-01
John MA 330-01
Alexa MA 330-01
Jose FN 361-01
Dave FN 361-01
Steve FN 361-01
Parker FN 361-01
Robert FN 361-01
Thank you!
Let me see if I can create a generic video that teaches people stuff and helps you out.
Thank you very much!
Great, now do the UTF!
Thnx man ;)
I don't know if someone will answer me: how can I save the first character of a string , for example
char c;
char * string;
string="hello";
c=getc(string); //someone told this could work but it doesn't work
Please help
The answer is "string[0]".
Example:
#include
void main(void) {
char c;
char *string = "hello";
c = string[0];
printf("%c", c);
}
@@EngineerMan thank you so much! Sorry to bother you... and what if a want to give my variable "string" any other value, do I must use scanf?
char c;
char *string;
scanf("%s", string);
c = string [0];
printf("%c", c);
This would be ok?
Just about. You'll need to allocate space first.
thank you!
Great!
name[0] *(name + 0) *(0 + name) 0[name]
werid but fun, :D, thanks