Instant file size result even on an old XT 8088: fseek(file, 0L, SEEK_END); total = ftell(file); rewind(file); But it's nice that you gave the viewers a memory management bonus lesson. :)
That said... I'm trying to find documentation that fseek() and ftell() will give us an "instant" result but I can't find anything (yet). It seems like the performance may be dependent on the implementation of the functions, but again I can't find much yet.
Thank you so much for the explanation and simple, easy to follow examples you provide. I managed to score A on my final exam only because of your videos. Immensely appreciated! Easy SUB!
Wahoo congratulations on scoring an A on your final exam!!! 🙌 🥳 And you're very welcome, I'm so glad to hear the videos have been helpful for you. Thank you for the sub and welcome aboard! :-)
@@PortfolioCourses Not at all, I mean I basically spent all night, no sleep and excited at being able to finally understand and apply true C with greater confidence than ever. It's the way you deliver the content that makes it so engaging and addictive to follow. This morning I've been able to tackle the problem I've been sitting on for a while. I really didn't think I had it in me to tackle the problem but binging on your videos has changed this. May your subs keep rising!
@@gerdsfargen6687 That's really awesome to hear that, thanks so much for sharing that with me. I'm super glad these videos are helping you out, and I hope you continue on your journey as a programmer with lots of success! 😀
I think using stat, calloc, and fread might be even more optimized. But I like the way you take us through this tutorial. Just subscribed to the channel. 👍
Weldone boss. I love you. kindly consider do an explanatory video about bit manipulations, their uses and how.. especially with number.. odd numbers, even numbers and other applications
bro you are so underrated came to your channel and got answers for those questions which i think that was none sense and finally getting 5th heart......
That’s awesome I’m glad these videos are helping you out! :-) Any help spreading the word about the channel in Facebook groups or whatever other channels is definitely appreciated, if you can think of other people that would benefit from it too.
Hi, I wanted to ask if you have a char array, where we have stored lines from a file, is there a way to check the type of the elements stored? So, for example if you iterate through the char array, that contains lines from a file, you come across a digit , convert it to a double. I'm working on a calculator project in c , that requires me to push elements of type double onto a stack and perform operations on them, once we come across a string in the file. However, I'm having difficulties converting the lines to ints and pushing them onto the stack. Is there anyway you could help? Thanks.
@@PortfolioCourses Hi, the user has provides the input. So each line contains either an int or a string. The string is an operation: add, multiply, divide etc and the numbers are what the operations are performed on. So the example input that will be added to the file is: 1-new line-2-newline-add-newline-3-newline-4-newline-subtract. I've stored the values in a char array and have made a dynamic stack. The idea is I read each line from the file and if it is an integer, I push this onto the stack and if I come across an operation I perform that operation on the digits in the stack, pop off those digits and push the answer to the top. I need help with converting the digits to a double type as my stack is of this type. Thanks.
@@atiyahussain3837 Hmmm this might help with the conversion: th-cam.com/video/UQOlTdArCRo/w-d-xo.html. 🙂 I don't think I can do a video on this soon but it sounds like an interesting problem, I've added it to my video idea list.
This video helped a lot so thank-you. However i'm trying to do this exact thing except store each line of the file into a 2D string array so each line is it's own string. Would it be better to just use the method you have shown then use strtok() with \0 as the delimiter or is there a better way to go about this? Thanks Subscribed
Great question! Hmm, I made this video on reading the lines of a file into an array of strings: th-cam.com/video/X-1qodkHCHo/w-d-xo.html. Maybe that video can help you? And welcome aboard! :-)
Did you have a question Ivan, or are you just wanting to share this code? :-) That is totally OK if that is the case, thank you for sharing the code with others.
Some of the best, most straightforward C tutorials on TH-cam!
Thank you for the very positive feedback, that's much appreciated! :-)
Instant file size result even on an old XT 8088:
fseek(file, 0L, SEEK_END);
total = ftell(file);
rewind(file);
But it's nice that you gave the viewers a memory management bonus lesson. :)
Yep, that'll work too. :-)
That said... I'm trying to find documentation that fseek() and ftell() will give us an "instant" result but I can't find anything (yet). It seems like the performance may be dependent on the implementation of the functions, but again I can't find much yet.
Thank you so much for the explanation and simple, easy to follow examples you provide. I managed to score A on my final exam only because of your videos. Immensely appreciated! Easy SUB!
Wahoo congratulations on scoring an A on your final exam!!! 🙌 🥳 And you're very welcome, I'm so glad to hear the videos have been helpful for you. Thank you for the sub and welcome aboard! :-)
Your content is incredible.
Thank you very much for the kind feedback! :-D
@@PortfolioCourses Not at all, I mean I basically spent all night, no sleep and excited at being able to finally understand and apply true C with greater confidence than ever. It's the way you deliver the content that makes it so engaging and addictive to follow.
This morning I've been able to tackle the problem I've been sitting on for a while. I really didn't think I had it in me to tackle the problem but binging on your videos has changed this.
May your subs keep rising!
@@gerdsfargen6687 That's really awesome to hear that, thanks so much for sharing that with me. I'm super glad these videos are helping you out, and I hope you continue on your journey as a programmer with lots of success! 😀
@Portfolio Courses your videos really are something else! Thank you 😊
I think using stat, calloc, and fread might be even more optimized.
But I like the way you take us through this tutorial. Just subscribed to the channel.
👍
Maybe I can make a video where we do it that way instead! Thank you for subscribing, and welcome aboard! :-)
Weldone boss. I love you.
kindly consider do an explanatory video about bit manipulations, their uses and how.. especially with number.. odd numbers, even numbers and other applications
Haha thanks! And maybe I can do more videos on bit manipulations. Right now I have this video: th-cam.com/video/WBim3afbYQw/w-d-xo.html. :-)
Waw.. I love you...
Please do more on the various applications.
@@D_Ladybug Cool, I'll add that to my list of video ideas. 🙂
bro you are so underrated came to your channel and got answers for those questions which i think that was none sense and finally getting 5th heart......
That’s awesome I’m glad these videos are helping you out! :-) Any help spreading the word about the channel in Facebook groups or whatever other channels is definitely appreciated, if you can think of other people that would benefit from it too.
Yeh tommorow i go to college and tell all my friends about you bro
Awesome, thanks so much! :-)
Hi, I wanted to ask if you have a char array, where we have stored lines from a file, is there a way to check the type of the elements stored? So, for example if you iterate through the char array, that contains lines from a file, you come across a digit , convert it to a double. I'm working on a calculator project in c , that requires me to push elements of type double onto a stack and perform operations on them, once we come across a string in the file. However, I'm having difficulties converting the lines to ints and pushing them onto the stack. Is there anyway you could help? Thanks.
Great question Atiya! :-) Do you know the exact format of the file? Does each line contain one int? It would depend on the format of the file.
@@PortfolioCourses Hi, the user has provides the input. So each line contains either an int or a string. The string is an operation: add, multiply, divide etc and the numbers are what the operations are performed on. So the example input that will be added to the file is: 1-new line-2-newline-add-newline-3-newline-4-newline-subtract. I've stored the values in a char array and have made a dynamic stack. The idea is I read each line from the file and if it is an integer, I push this onto the stack and if I come across an operation I perform that operation on the digits in the stack, pop off those digits and push the answer to the top. I need help with converting the digits to a double type as my stack is of this type. Thanks.
@@atiyahussain3837 Hmmm this might help with the conversion: th-cam.com/video/UQOlTdArCRo/w-d-xo.html. 🙂 I don't think I can do a video on this soon but it sounds like an interesting problem, I've added it to my video idea list.
How do we make a string array for each line instead of just one big string?
This video may help you with that: th-cam.com/video/X-1qodkHCHo/w-d-xo.html. :-)
This video helped a lot so thank-you. However i'm trying to do this exact thing except store each line of the file into a 2D string array so each line is it's own string. Would it be better to just use the method you have shown then use strtok() with \0 as the delimiter or is there a better way to go about this? Thanks Subscribed
Great question! Hmm, I made this video on reading the lines of a file into an array of strings: th-cam.com/video/X-1qodkHCHo/w-d-xo.html. Maybe that video can help you? And welcome aboard! :-)
you can do what you want!
Yep!
9:02
Is there something at this point in the video I should know about? 🙂
#include
#include
#include
typedef struct studenti
{
char ime[20],prezime[20];
int ocena;
double prosek;
struct studenti *sledeci;
}STUDENTI;
STUDENTI *napravi(char *ime, char *prezime, int ocena)
{
STUDENTI *novi=(STUDENTI*)malloc(sizeof(STUDENTI));
strcpy(novi->ime,ime);
strcpy(novi->prezime,prezime);
novi->ocena=ocena;
novi->sledeci=NULL;
return novi;
}
STUDENTI *dodaj(STUDENTI *glava, char *ime, char *prezime, int ocena)
{
STUDENTI *novi=napravi(ime, prezime, ocena);
if (glava==NULL)
{
glava=novi;
return glava;
}
novi->sledeci=glava->sledeci;
glava->sledeci=novi;
}
STUDENTI *ucitaj(STUDENTI *glava,char*fajl)
{
FILE *fp=fopen(fajl,"r");
char linija[150], ime[25], prezime[25];
int ocena;
int pr=0;
int suma=0;
while(fgets(linija,sizeof(linija),fp))
{
char *token=strtok(linija," ");
int br=0;
while(token!=NULL)
{
if(br==0) strcpy(ime,token);
if(br==1) strcpy(prezime,token);
if(br==2)
{
ocena=atoi(token);
pr++;
suma=suma+ocena;
}
br++;
token=strtok(NULL," ");
}
glava=dodaj(glava,ime, prezime, ocena);
}
return(glava);
}
void printaj(STUDENTI *glava)
{
if (glava==NULL)
{
printf("KRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJ");
return;
}
printf("%s %s %d
",glava->ime,glava->prezime,glava->ocena);
printaj(glava->sledeci);
}
void prosek(STUDENTI *glava)
{
double suma=0.0;
double prosek=0.0;
int br=0;
STUDENTI *tmp=glava;
while(tmp!=NULL)
{
br++;
suma+=tmp->ocena;
tmp=tmp->sledeci;
}
prosek=suma/br;
printf("Prosek je: %f",prosek);
}
Did you have a question Ivan, or are you just wanting to share this code? :-) That is totally OK if that is the case, thank you for sharing the code with others.