[C Video Tutorial Collection]

This is a discussion on [C Video Tutorial Collection] within the C Programming forums, part of the General Programming Boards category; Ok here is my list of video tutorials ive recorded, keep checking back in this thread as ill be adding ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    8

    Thumbs up [C Video Tutorial Collection]

    Ok here is my list of video tutorials ive recorded, keep checking back in this thread as ill be adding new videos all the time.

    Download #1 Hello World: http://www.mediafire.com/?aknneutiyft
    View #1 Hello World: www.console-world.org/HelloWorld.htm

    Download #2 Variables: http://www.mediafire.com/?c3hynozwzz0
    View #2 Variables: www.console-world.org/Variables.htm

    Download #3 Data Types: http://www.mediafire.com/?2ymmmmhg21t
    View #3 Data Types: www.console-world.org/Datatypes.htm

    Download #4 User Input: http://www.mediafire.com/?1dzjqmmwynz
    View #4 User Input: www.console-world.org/Userinput.htm

    Download #5 Comments: http://www.mediafire.com/?eyvrgf0wojy
    View #5 Comments: www.console-world.org/Comments.htm

    Download #6 Arithmetic: http://www.mediafire.com/?5zjz4ze0mjo
    View #6 Arithmetic: www.console-world.org/Arithmetic.htm

    Download #7 For Loops: http://www.mediafire.com/?4jyy0fd4j2n
    View #7 For Loops: www.console-world.org/ForLoops.htm

    Download #8 Do Loops: http://www.mediafire.com/?aney10zmndw
    View #8 Do Loops: www.console-world.org/DoLoops.htm

    Download #9 While Loops: http://www.mediafire.com/?0cwxam3uynu
    View #9 While Loops: www.console-world.org/WhileLoops.htm

    Download #10 Functions: http://www.mediafire.com/?0cwxam3uynu
    View #10 Functions: www.console-world.org/Functions.htm

    Download #11 If Statements: http://www.mediafire.com/?0cwxam3uynu
    View #11 If Statements: www.console-world.org/IfStatements.htm

    Download #12 Switch: http://www.mediafire.com/?7zxqnnymnwz
    View #12 Switch: www.console-world.org/Switch.htm

    Download #13 Strings: http://www.mediafire.com/?9toouzozymz
    View #13 Strings: www.console-world.org/Strings.htm

    Download #14 Arrays: http://www.mediafire.com/?9rlz1m5mtmz
    View #14 Arrays: www.console-world.org/Arrays.htm

  2. #2
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    Dude, pink?
    Plus you're using void main()... Get standard. Man.
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  3. #3
    Registered User Noir's Avatar
    Join Date
    Mar 2007
    Posts
    218
    That's cool, mate. I really appreciate the effort you put into making videos and putting them up for us to learn from. I only looked real quick at the arrays video, and the "I don't know what it does" comment kind of put me off. If we're going out of our way to compile as C, shouldn't we at least know why?

    The answer to that one is that compiling as C does stuff like disable some C++ keywords like 'new' so they can be used as variables, and reduce static type checking for things like conversion between void pointers and other pointers. C and C++ aren't the same, so changing the switch tells the compiler that you really are using C and not a C subset of C++ that can cause subtle and hard to find bugs if you think you're using C.

    I'll watch the rest of them and let you know what I think.

    Edit: Functions and If Statements both point to While Loops, and Strings doesn't let me download.
    Last edited by Noir; 04-04-2007 at 08:49 AM.

  4. #4
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,750

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  6. #6
    Registered User
    Join Date
    Apr 2007
    Posts
    8
    Yea i only mentioned the compile as C code things because i just noticed it the other day, i havent had time to find out exactly what it did. But yes i assumed it did what you said, however i didnt want to say that incase i was wrong.

    Oh and my IDE isnt normally pink its grey, it only turns out like that due to me setting the video output as low quality, which lowers the file size

    Oh and about void main() if you watch the first video i explain why i do that.

  7. #7
    Captain - Lover of the C
    Join Date
    May 2005
    Posts
    341
    Real men wear pink. I like the accent. Most importantly,your tutorials may not be the most accurate thing I've ever heard, but they do the best job of explaining concepts that I've seen. void main() should be int main(). I heard your reasoning, but int main() is better.
    Rating: ****
    Don't quote me on that... ...seriously

  8. #8
    Registered Abuser
    Join Date
    Jun 2006
    Location
    Toronto
    Posts
    591
    Any particular reason why a short int is used as an iteration variable in the video on for loops?

  9. #9
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    In the first video you first use
    Code:
    main(void) {
    
    }
    with the explanation basically that if you don't care about the return int, this wouldn't generate it. But it does - it returns int whether you want it to or not. Leaving out the return type just causes it to default to int (if I'm not mistaken this is limited to C89, and that C99 requires an explicit return type). I know that K&R2 does this, but it's bad practice today. Since C89 allows explicit return type int, it's better to put it in to future-proof the code for when C99 mode is used by default. Then you say that for those people who like to use return type int, use
    Code:
    int main() {
    
    }
    which is okay. Since in C (I'm not sure if it's limited to C89) a function definition without arguments means that the number of arguments is undetermined, it might be better to use
    Code:
    int main(void) {
    
    }
    just for consistency with other functions with no arguments where it matters more. In C++ there would be no reason to put "void" there since giving no arguments means unambiguously that there aren't any.

    Edit: I think I confused function definitions with declarations - the definition would have to specify any arguments, but any declarations could leave them out. In general, though, putting "void" there for both the definition and any declaration of a given function is good for consistency since it makes them look the same.
    Last edited by robatino; 04-04-2007 at 08:52 PM.

  10. #10
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Good!

    In leason 3, you say a character can't be an integer, but in fact a char is defined as int8 (8 bit integer...).

    Also how much a variable can 'hold' depends on your environment, look in limits.h for more details. Also read the C draft.

    Out of curiosity, where does your accent come from? (day-ta, steeddeeyo )

    The standard says that a long int must be large enough to house a int, short int ect... (usually long int == int)
    Last edited by zacs7; 04-04-2007 at 09:19 PM.

  11. #11
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Little bit more on the return type of main just for fun...

    For x86 systems.... the return value of a function is generally found inside the EAX register of the CPU. That means whatever is found inside EAX will be your return value for main() as well as any function that you call.

    Needless to say, that is not the only purpose of the EAX register, and it will/can be overwritten for other basic calculations and such, but one of the side effects of this is that if you call a function right before main() ends, you could implicitly be passing the return value of another function as main()'s return value. If that function returns void, the fun gets even better.

    Proof of concept? Take the following three programs:

    Code:
    #include <stdio.h>
    
    void main()
    {
    	printf("Bleh!\n");
    }
    Code:
    #include <stdio.h>
    
    int main()
    {
    	int iRet;
    	printf("Enter a return value for this program: ");
    	scanf("%d",&iRet);
    	return iRet;
    }
    Code:
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    
    int getProgram(char *, size_t);
    
    int main()
    {
    	int iRet;
    	char szProgram[256];
    	
    	while(getProgram(szProgram,sizeof(szProgram)))
    	{
    		iRet = system(szProgram);
    		printf("Return value of \"%s\":\t%d\n\n",szProgram,iRet);
    	}
    	return 0;
    }
    
    int getProgram(char *szProgram, size_t size)
    {
    	int iLength;
    	
    	printf("Enter a program name or \"exit\" to leave: ");
    	
    	if(!fgets(szProgram,size,stdin))
    	{
    		fprintf(stderr,"Error reading from stdin.\n");
    		return 0;
    	}
    	iLength = strlen(szProgram);
    	if(szProgram[iLength-1] == '\n')
    	{
    		szProgram[iLength-1] = '\0';
    	}
    	return strcmp(szProgram,"exit");
    }
    The first program is rather obvious, as is the second. The third program keeps asking the user for a program to run, passes the argument to the shell, and then receives the return value from the shell, which will be the return value of the program that you run.

    To see my point, you could run the last program and input the name of the first program. You should get a return value of 6. Why? Because printf() returns the amount of chars that it printed, which in this case is 6 chars, 'B', 'l', 'e', 'h', '!', and '\n'. This return value is stored in the EAX register regardless of whether or not you need it or use it.

    Since there is no explicit return in main() in the first program, and no other instructions, the return value of printf() just sits there collecting dust until your program ends. The shell then takes that same value in EAX as the value that you intended to return from main() since it doesn't give a care how you declared main(). It just knows to that you're supposed to give it a number.

    For a program that simple, the return value is guaranteed to be constant. For some programs, however, it's totally possible that the last value inside EAX could be "random" depending upon various factors, such as how your program is run. If you run the second program, obviously, whatever you give to scanf() will be returned, value or invalid.

    For example, I ran the last program and when prompted to run a program, I chose to run the second one. When then prompted to enter a value, I entered 'x', which is obviously not a valid integer. The return value was 4231228.

    Even if you never use the return value, imo, it is a good idea to get into the habit of declaring main() as returning an integer and explicitly returning a value. This way, you can actually make use of the return value and signify if any errors occurred in your program or if the user can expect that everything went well.

  12. #12
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    Upon checking the FAQ on declaring main:

    http://faq.cprogramming.com/cgi-bin/...&id=1043284376

    it appears that C99 _requires_ that if main() takes no arguments, then it has to be declared as
    Code:
    int main(void) {
    so putting the void there is good for future-proofing.

  13. #13
    Registered User
    Join Date
    Apr 2007
    Posts
    8
    Thanks for all your input guys, im not the best coder (and i sure dont say i am lol) but these videos were mainly designed at total beginners which is why i dont go into massive detail

    Oh and for the record im Australian thats why i have the odd accent

  14. #14
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Quote Originally Posted by Chernobyl View Post
    Thanks for all your input guys, im not the best coder (and i sure dont say i am lol) but these videos were mainly designed at total beginners which is why i dont go into massive detail

    Oh and for the record im Australian thats why i have the odd accent
    Really, Cause im Aussie too, and I say, Darta and std-io

  15. #15
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,750
    I just want it to be clear that we don't expect you to go in massive detail. Knowing where to sprinkle "details" is the secret to producing something of value. A good tutorial is like a good essay: it keeps the audience in mind, is factual, and engaging. Like any industry programmers have standards and the main gripe of the people in this thread is that your demonstrating, encouraging (somewhat) the same mistakes that people can learn about and use, and yet you put yourself in a position of teaching something to the unwary. That's why dwks and I originally posted links to references without saying anything else.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem With My Box
    By HaVoX in forum Tech Board
    Replies: 9
    Last Post: 10-15-2005, 08:38 AM
  2. Codec Bitrates?
    By gvector1 in forum C# Programming
    Replies: 2
    Last Post: 06-16-2003, 09:39 AM
  3. OpenGL .dll vs video card dll
    By Silvercord in forum Game Programming
    Replies: 14
    Last Post: 02-12-2003, 07:57 PM
  4. Drawing a circle in a video captured frame
    By skyhigh in forum C Programming
    Replies: 2
    Last Post: 12-05-2001, 01:00 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21