Thread: I am a very new C student; I want to your help in creating "random video sequence sw"

  1. #16
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Umm...that's not C++ either, and I'm not sure that C++ would help you. Besides, you're cross-posting in two forums, getting the same advice from several people in both places, and refusing to listen to any of it. You're wasting our time and that of the nice people at doom9.org. Just learn to program, then tackle this problem. Come back when you're not going to ask C programmers on a C programming forum to analyze some Avisynth script you don't understand. You have along way to go brother, and they haven't invented teleporters yet, so you gotta take that road step by step. We'll always be here to help you along the way if you have valid C questions.

  2. #17
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by anduril462 View Post
    Umm...that's not C++ either, and I'm not sure that C++ would help you. Besides, you're cross-posting in two forums,
    Ok... I just deleted my last response on this and looked at the doom9 forums... You're right, he's not listening.
    Thanks for the heads up!

  3. #18
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    From that topic:

    This is a movie shuffler in an Avisynth script:
    it's a script for the program, not C or C++ or anything useful outside of that program.

  4. #19
    Registered User
    Join Date
    Apr 2011
    Posts
    308
    I have some new code, and maybe CommonTater can look it over and add a comment.

    Here is what I use to compile it in visual studio 2010 cmd prompt:
    Code:
    cl /EHsc samp.cpp
    Here is the results I get when I run the exe I compile:

    Code:
    C:\Users\Brian\Desktop>samp.exe
    Contents of variables 'one' to 'twenty-seven':
    1 2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 26 27
    
    Press 'Return' to quit
    
    
    C:\Users\Brian\Desktop>
    Here is the code, it's got to go into a cpp file since the code uses iostream:

    Code:
    #include <iostream>
    
    #include <stdio.h>
    
    typedef struct movie {
        int audio;
        double fps;
    } Movie;
    
    int main( void )
    {
        Movie movies[27];
        int one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen, twenty, twenty_one, twenty_two, twenty_three, twenty_four, twenty_five, twenty_six, twenty_seven;
    
    one=1;
    two=2;
    three=3;
    four=4;
    five=5;
    six=6;
    seven=7;
    eight=8;
    nine=9;
    ten=10;
    eleven=11;
    twelve=12;
    thirteen=13;
    fourteen=14;
    fifteen=15;
    sixteen=16;
    seventeen=17;
    eighteen=18;
    nineteen=19;
    twenty=20;
    twenty_one=21;
    twenty_two=22;
    twenty_three=23;
    twenty_four=24;
    twenty_five=25;
    twenty_six=26;
    twenty_seven=27;
    
    /*break one*/
    
    if((twenty_five<=twenty_six)&&(twenty_six>=twenty_four)){
    	twenty_five=twenty_three;
    }
    else{
    	twenty_five=twenty_five;
    }
    
    /*break two*/
    
    if((twenty_four<=twenty_five)&&(twenty_five>=twenty_three)){
    	twenty_four=twenty_two;
    }
    else{
    	twenty_four=twenty_four;
    }
    
    /*break three*/
    
    if((twenty_three<=twenty_four)&&(twenty_four>=twenty_two)){
    	twenty_three=twenty_one;
    }
    else{
    	twenty_three=twenty_three;
    }
    
    /*break four*/
    
    if((twenty_two<=twenty_three)&&(twenty_three>=twenty_one)){
    	twenty_two=twenty;
    }
    else{
    	twenty_two=twenty_two;
    }
    
    /*break five*/
    
    if((twenty_one<=twenty_two)&&(twenty_two>=twenty)){
    	twenty_one=nineteen;
    }
    else{
    	twenty_one=twenty_one;
    }
    
    /*break six*/
    
    if((twenty<=twenty_one)&&(twenty_one>=nineteen)){
    	twenty=eighteen;
    }
    else{
    	twenty=twenty;
    }
    
    /*break seven*/
    
    if((nineteen<=twenty)&&(twenty>=eighteen)){
    	nineteen=seventeen;
    }
    else{
    	nineteen=nineteen;
    }
    
    /*break eight*/
    
    if((eighteen<=nineteen)&&(nineteen>=seventeen)){
    	eighteen=sixteen;
    }
    else{
    	eighteen=eighteen;
    }
    
    /*break nine*/
    
    if((seventeen<=eighteen)&&(eighteen>=sixteen)){
    	seventeen=fifteen;
    }
    else{
    	seventeen=seventeen;
    }
    
    /*break ten*/
    
    if((sixteen<=seventeen)&&(seventeen>=fifteen)){
    	sixteen=fourteen;
    }
    else{
    	sixteen=sixteen;
    }
    
    /*break eleven*/
    
    if((fifteen<=sixteen)&&(sixteen>=fourteen)){
    	fifteen=thirteen;
    }
    else{
    	fifteen=fifteen;
    }
    
    /*break twelve*/
    
    if((fourteen<=fifteen)&&(fifteen>=thirteen)){
    	fourteen=twelve;
    }
    else{
    	fourteen=fourteen;
    }
    
    /*break thirteen*/
    
    if((thirteen<=fourteen)&&(fourteen>=twelve)){
    	thirteen=eleven;
    }
    else{
    	thirteen=thirteen;
    }
    
    /*break fourteen*/
    
    if((twelve<=thirteen)&&(thirteen>=eleven)){
    	twelve=ten;
    }
    else{
        twelve=twelve;
    }
    
    /*break fifteen*/
    
    if((eleven<=twelve)&&(twelve>=ten)){
    	eleven=nine;
    }
    else{
    	eleven=eleven;
    }
    
    /*break sixteen*/
    
    if((ten<=eleven)&&(eleven>=nine)){
    	ten=eight;
    }
    else{
    	ten=ten;
    }
    
    /*break seventeen*/
    
    if((nine<=ten)&&(ten>=eight)){
    	nine=seven;
    }
    else{
    	nine=nine;
    }
    
    /*break eighteen*/
    
    if((eight<=nine)&&(nine>=seven)){
    	eight=six;
    }
    else{
    	eight=eight;
    }
    
    /*break nineteen*/
    
    if((seven<=eight)&&(eight>=six)){
         seven=five;
    }
    else{
    	seven=seven;
    }
    
    /*break twenty*/
    
    if((six<=seven)&&(seven>=five)){
    	six=four;
    }
    else{
    	six=six;
    }
    
    /*break twenty_one*/
    
    if((five<=six)&&(six>=four)){
    	 five=three;
    }
    else{ 
    	five=five;
    }
    
    /*break twenty_two*/
    
    if((four<=five)&&(five>=three)){
    	 four=two;
    }
    else{
    	four=four;
    }
    
    /*break twenty_three*/
    
    if((three<=four)&&(four>=two)){
    	 three=one;
    }
    else{
    	three=three;
    }
    
    /*break twenty_five*/
    
    	// Output the contents of the variables
    	std::cout << "Contents of variables 'one' to 'twenty-seven':" << std::endl;
    	std::cout << one          << " " 
    			  << two          << " "
    			  << three        << " "
    			  << four         << " "
    			  << five         << " "
    			  << six          << " "
    			  << seven        << " "
    			  << eight        << " "
    			  << nine         << " "
    			  << ten          << " "
    			  << eleven       << " "
    			  << twelve       << " "
    			  << thirteen     << " "
    			  << fourteen     << " "
    			  << fifteen      << " "
    			  << sixteen      << " "
    			  << seventeen    << " "
    			  << eighteen     << " "
    			  << nineteen     << " "
    			  << twenty       << " "
    			  << twenty_one   << " "
    			  << twenty_two   << " "
    			  << twenty_three << " "
    			  << twenty_four  << " "
    			  << twenty_five  << " "
    			  << twenty_six   << " "
    			  << twenty_seven << std::endl << std::endl;
    
    for ( one = 1; one <= twenty_seven; ++one ) {
            /* the name of the movie file corresponds to the array element 
             * e.g. movie "5.mp4" is movies[5], movie "6.mp4" is movies[6]...
             */
            movies[one].audio = 0;
            movies[one].fps   = 23.976;
        }
    
    	std::cout << "Press 'Return' to quit" << std::endl;
    	std::cin.get();
    
        return 0;
    }
    So the code works now, but how to change the variable name value to match the number of frames from the video clip?
    And as a add note, I read you write that this forum has a c guide so I actualy am reading that and read it a bit today; that's where I got the instruction for how to write this code. I got some help from somebody and he wrote the code so you could see the results in a lis of numbers, but I wrote the main code itself, with the help of kmess!

  5. #20
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    You want my comment... Ok... same as before. It's crap.

    If you actually knew anything about programming and C you could probably reduce that horrible mess to 20 lines or less.

    And just as before... you seriusly need to set this aside --simply give up on it-- for as long as it takes you to go through a complete training manual for C... as I said, page by page, example by example, quiz by quiz. After you do that and come back to this code of yours, you will agree with my assessment, I guarantee it.

    Start here... Teach Yourself C in 21 Days -- Table of Contents

    Some here don't like this tutorial, but it's a pretty gentle introduction that anyone should be able to follow.

  6. #21
    Registered User
    Join Date
    Apr 2011
    Posts
    308
    Hi CommonTater,

    I want to know if this code;

    Code:
    C:\Users\Brian\Desktop>samp.exe
    Contents of variables 'one' to 'twenty-seven':
    1 2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 26 27
    
    Press 'Return' to quit
    
    
    C:\Users\Brian\Desktop>
    Can be reproduced by this "20 lines of codes". So assume the int values are the same, with this new code you speak of I will get the same answer Every time I run the program?
    And, that I can add frame numbers to the int variable names?

    I think I like the course on C from this sites faq. But after I get through that I will check out that one you linked too as well.

  7. #22
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547

    Just to prove a point...

    Code:
    #include <stdio.h>
    #include <time.h>
    
    int main (void)
      { int play[25];
         int x, y, t;
         // init random sequence
         srand(time(NULL));
         // init array
         for (x = 0; x < 25; x++)
           play[x] = x + 2;
         // shuffle playlist
         for ( x = 24; x > 0; x--)
           {  y = rand()  % x;
               t = play[y];
               play[y] = play[x];
               play[x] = t; }
         // output result
         printf("\n1 ");
         for (x = 0; x < 25; x++)
           printf("%d ", play[x]);
         printf("27\n\n");
        return 0; }
    Not counting comments... 19 lines.
    Last edited by CommonTater; 04-27-2011 at 02:09 AM.

  8. #23
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Keep trying; maybe someone will hand you the code you're seeking so you don't really have to learn.

  9. #24
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by rags_to_riches View Post
    Keep trying; maybe someone will hand you the code you're seeking so you don't really have to learn.
    It is starting to look that way, isn't it?

    He doesn't seem at all interested in actually learning C... just messing with this icky program he's thought up.

  10. #25
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    @jeremy duncan
    Code:
    1 2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 26 27
    You know you're playing frame 1 twice and skipping frame 25, right? Is that really what you want? Your "random" order is basically reversing pairs of numbers, and you said you wanted a fixed order, so really, the fact that you're using any logic to determine the order is just ridiculous. As we've all said, that code you have is crap. You need to learn the language before writing this, and learn to think about your problem until you understand it thoroughly. Then start coding.

  11. #26
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Heck... if all he wants is a fixed order...

    Code:
    #include <stdio.h>
    
    int main (void)
      { int play[27] = { 1,23,18,11,20,24,13,22,2,8,15,21,5,4,19,6,14,16,12,2,25,26,7,17,10,9,27}
        for( int x = 0; x < 27; X++)
           printf("%d ",play[x]);
        printf("\n\n");
        return 0; }
    8 lines....
    Last edited by CommonTater; 04-27-2011 at 12:13 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. "itoa"-"_itoa" , "inp"-"_inp", Why some functions have "
    By L.O.K. in forum Windows Programming
    Replies: 5
    Last Post: 12-08-2002, 08:25 AM
  2. "CWnd"-"HWnd","CBitmap"-"HBitmap"...., What is mean by "
    By L.O.K. in forum Windows Programming
    Replies: 2
    Last Post: 12-04-2002, 07:59 AM
  3. Replies: 3
    Last Post: 01-14-2002, 05:09 PM
  4. escape sequence "\ooo" and "\xhhh"
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 12-01-2001, 09:30 PM

Tags for this Thread