Thread: Give me some homework

  1. #31
    Registered User
    Join Date
    Apr 2017
    Location
    Iran
    Posts
    138
    Quote Originally Posted by ImageJPEG View Post
    I actually have quite a few opensource projects downloaded. I've downloaded the Linux kernel, OpenBSD kernel and userland, and a few others.
    Maybe you could start by some trivial game like Tic-tac-toe.

  2. #32
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    1,110
    Quote Originally Posted by ImageJPEG View Post
    I actually have quite a few opensource projects downloaded.

    I've downloaded the Linux kernel, OpenBSD kernel and userland, and a few others.
    I would avoid even looking at kernel code. Perhaps you should look at the GNU Coreutils, which can be downloaded here.

    You can see how Linux libraries, and tools were created!

  3. #33
    Banned
    Join Date
    Aug 2017
    Posts
    861
    First off this entire so called argument is stupid, and I did not start it. Now you can try to figure out what that means,

    Quote Originally Posted by whiteflags View Post
    Fine.

    And you're so butthurt that when you post complete code anymore you have to beg not to be "attacked." Such humility.
    "butthurt" is that some kind of polite way of saying, ........ed in the ass? so what are you really trying to say here is that you're a little ass ........er, or like being one?

    Because Humility has nothing to do with what I said in that statement. So it seems clear you have no understanding on humility or what it is or how it is used either, because that does not even apply in any of that statement you are trying to pick apart and find fault in it.

    Any excuse to avoid feeling guilty about looking up complete solutions on the internet at the first sign of trouble.
    Look at yourself, here you are trying your hardest to try and tear me apart for not completely reading through something then acting on it, and here you are doing the same in your attempt to try and prove something about yourself.

    you do not even understand yourself let alone others, Your are now spitting out conclusions from only half a thought your own self causing you to miss the complete picture here as well.

    If I can look up the solutions to their problems on the internet . Then what is preventing them from doing the same?

    Like I said before 95 ish percent of the answers are already out there and published. All one has to do is look and they will find them, you even sighted stuff off of a different web sight to substantiate what you where trying explain.

    So if you know how to look and find the information you need to do what you need to do, and I can find the information to do what I need to do, ( setting aside that liitle hick up) then what is preventing someone else from doing the same?

    all anyone has to do is type in what it is they are wanting to do then look at the results of what comes up.

    I have already found one or two of theses assignments posted on other web sights asking the same exact questions with answers to them already posted. From "years" gone by. Just siting there waiting for someone else to find them and put them to use.

    All one has to do is search out what they need to do, even little pieces of it then if they teaches themselves how to put code together and how to test it properly they will eventually get it to do what they need it to do.

    Teach themselves how and what to look for, over time they will eventually begin picking up on it. Coding know what to write or even close to it, the logic behind what they need to do so it will work, then all that is left is figuring out that what they need to use and how to use it to get it to do what they need it to do.

    Just showing them the answers on how to do one thing, or a line of operations is not a bad thing. the bad thing is if they do not take that and work with it, pick it apart and examine it to see how it is doing what it is doing.

    Try apply it else where and seeing how that same code effects their new code that is written around it. Figuring out how to modify that same code to make it now work with what they are doing in that situation.

    Showing someone exactly how to ride a bike. Now they have their answer. All they now need to do is work with it to learn how to make that answer work for them so it gets them where they need to be.

    it is no different, if they get the answer right off, but do not take that time to work with it to better understand how it works for them that need to do such things.

    The student is responsible for understanding the knowledge he or she has gained and how to put it to good use not the one that gives it to them.


    Sounds like a distinction without a difference to me. If you understand why something would work, then you would write it, and it would freaking work. Imagine that.
    see how that works? the only think missing there in that is what?

    I know that if I put a nail in that wall then I could hang a picture on it.

    I know if I write it something like this ... that thought leads to getting what type of results?


    I know if I write it like this it will do what I want. that thought will get what type of results?

    I do not know my times tables. Does any one really know their times tables or is it just something they remembered because someone gave them a picture of it, then told them to learn your times table. Instead what really took place is memorizing it.

    Learning takes place in many forms it is understanding that now needs to be established, but that too is on a case by case basis.


    you can know how to drive a car

    Well, excuse me for being a little more cynical. I don't think the majority of people treat handouts as learning opportunities.
    who's fault if that?

    The person handing out the information or the person getting the information?

    2. you do not think, that is a statement of not knowing.You have not even put that to thought and yet here you are using it as your basis of argument against me.

    You sure do like to keep up this argument. How about you drop it already? If you really can't handle that I think differently about this then just ignore me.
    Looks to me you are going off half cocked relying on someone else way of teaching others how to program and not even looking at the big picture here.

    or how the "Establishment" of college has programed peoples mind to one way of thinking that benefits them and not the student in a long run. It keeps people being students and not teachers for one. Job security is one reason, money is another. if they have to keep retaking the class until they remember what to do to get something done to get a better grade so they can then take that to an employer and show them hey look I am a 4.0 student hire me and pay me the big bucks so I can be like you and make a bunch of money and feed my ego with it giving me that false belief that I now am better then the others because I know more then they do. and I am going to do the same thing "they" did to me to get it to everyone else that is looking to learn what I learned by the same means I had to learn it.

    by struggling. causes and effect. Making life hard for others just because someone else did that to them. Cruel and inhuman behavior.

    It is an evil that you are falling for by a society that does not really care about you. It just uses a means to make it look like they do while still getting what they want out of you by doing it. Your money that you need to survive in this world. So they can survive on it instead. Selfishness feeding off of unsuspecting trusting souls like you.

    Because behavior is learned. You then start to take on their way of thinking and accept it as your own only to pass it on keeping that lie alive. Like you got your head stuck in a bucket and all you know is what they taught you in how to teach others and that is it, and you don't really think about much of anything other than what they taught you so you teach the same way and that is it? And you probably do not even think about that, you just do it instead without a thought.

    Their is more to life then just programming you know, and more than one way to teach.

    It is the responsibility of the receiver to do with whatever knowledge they gain to understand it or not understand it, and how they put it to use or not put it to use. Not the giver of knowledge.

    The "society" tells its people you need a college education to get a good job.
    good job = more money to live on. More money to live on the better life I have to live. Buy buy buy everything I want go everywhere I want, do whatever I want, say whatever I want. I got money and power now. I am important human being. I am better now. better then you!

    Rose bud: go learn what message that had in it.


    Greed fosters poverty.

    "they" create this need to have a higher form of knowledge on how to do things that will make others grow depended on the product that provide to others that will make their lives easier. which in a long run all it does is further complicate them, and make them grow more lazier.

    I cannot change the channel to my tv because I have no remote control. They become too lazy to just get up and change the channel. put more effort in looking for that remote then just changing the channel. causing them to lose sight of what is really important. In that situation, it was just changing the channel on the TV. more time wasted then not to fix that situation.

    Cell Phones brings people closer to each other by giving them the means to instantly contact that other they feel they need to contact in an instance.

    Ever see two people sharing time together now. When all they are doing is looking at their cell phones. So much for bringing people closer together by that little piece of tech.

    You're just falling into the pit of life that just drags you down in a long run. while making you struggle throughout your life. Your entire time spent is on trying you make it rich or die trying so you will have a better life. Which is just a waste of life. because you cannot take it with you and it still leaves you with an empty feeling inside of you.

    and that is just a piece of the whole picture. Your all worried about the stupid S....... missing what is really important. Because it looks to me you're not thinking past your noise.

    It is the responsibility of the receiver to do with whatever knowledge they gain to not only understand it or not understand it, and how they put it to use or not put it to use. But to put it to the test first to be sure it is truth before they put it to use.
    Not the giver of knowledge. That goes for everything. Because we humans are all susceptible to mistakes, as well as all kinds of debauchery.

    that is just a piece of it. wrap your head around that first before you even think you know what to say about it.
    Last edited by userxbw; 11-06-2017 at 09:43 AM.

  4. #34
    Registered User
    Join Date
    Dec 2011
    Location
    Namib desert
    Posts
    94
    @userxbw: By now you have used enough bandwidth.
    Last edited by ddutch; 11-06-2017 at 09:56 AM.

  5. #35
    Registered User
    Join Date
    Apr 2017
    Location
    Iran
    Posts
    138
    Quote Originally Posted by ImageJPEG View Post
    I actually have quite a few opensource projects downloaded.

    I've downloaded the Linux kernel, OpenBSD kernel and userland, and a few others.
    Alternatively, you can try to use some of these open source C libraries.

  6. #36
    Registered User
    Join Date
    Sep 2017
    Posts
    93

  7. #37
    Registered User
    Join Date
    May 2012
    Location
    Arizona, USA
    Posts
    948
    Quote Originally Posted by ImageJPEG View Post
    I'd avoid learning from or using code from that site, considering they use "void main()" in many of their examples.

  8. #38
    Registered User
    Join Date
    Sep 2017
    Posts
    93
    Well here's what I currently have to check for multiple newlines in a row:

    Code:
            if(FileData == '\n')
            {
                fseek(fp, 1L, SEEK_CUR);
                FileData = getc(fp);
                if(FileData == '\n')
                {
                    fseek(fp, 1L, SEEK_CUR);
                    FileData = getc(fp);
                    if(FileData == '\n')
                        printf("Found!");
                    else
                        fseek(fp, -1L, SEEK_CUR);
                    printf("Hello!");
                }
                else
                    fseek(fp, -1L, SEEK_CUR);
            }
    Note that it doesn't really work at the moment but I think I'm on the right track...maybe?

  9. #39
    Registered User
    Join Date
    Sep 2017
    Posts
    93
    The "Found!" and "Hello!" are there to help me figure out what's going on.

  10. #40
    Registered User
    Join Date
    May 2012
    Location
    Arizona, USA
    Posts
    948
    I would not bother using fseek for this task for a number of reasons. It should be easy enough to read one character at a time and decide what to do with it.

    To suppress repeated newlines, I would use a variable to count the number of consecutive newline characters you read. If the character you just read is a newline, add one to the counter; otherwise set the counter to zero. If the newline counter is less than 3, print the character you read (and don't print anything if the counter is 3 or greater).

    Hopefully that should get you thinking about how to approach this problem.

  11. #41
    Registered User
    Join Date
    Apr 2017
    Location
    Iran
    Posts
    138
    Quote Originally Posted by ImageJPEG View Post
    Well here's what I currently have to check for multiple newlines in a row:

    Code:
            if(FileData == '\n')
            {
                fseek(fp, 1L, SEEK_CUR);
                FileData = getc(fp);
                if(FileData == '\n')
                {
                    fseek(fp, 1L, SEEK_CUR);
                    FileData = getc(fp);
                    if(FileData == '\n')
                        printf("Found!");
                    else
                        fseek(fp, -1L, SEEK_CUR);
                    printf("Hello!");
                }
                else
                    fseek(fp, -1L, SEEK_CUR);
            }
    Note that it doesn't really work at the moment but I think I'm on the right track...maybe?

    I suggest you to start a new thread for this question.

  12. #42
    Registered User
    Join Date
    Sep 2017
    Posts
    93
    Well, this is what I have for now. It sorta works.

    Code:
        FileData = getc(fp);
        
        while(FileData != EOF)
        {
            NewLineCounter = 0;
            while(FileData == '\n')
            {
                FileData = getc(fp);
                NewLineCounter++;
            }
            if(NewLineCounter > 3)
                printf("\n");
            else
            {
                printf("%c", FileData);
                FileData = getc(fp);
            }
            
            printf("%c", FileData);
            FileData = getc(fp);
        }
    Here's an image of the output. Real cat is executed first, then mine.

    Give me some homework-screen-shot-2017-11-07-10-42-02-pm-jpg

  13. #43
    Registered User
    Join Date
    Sep 2017
    Posts
    93
    I got it!

    Code:
        while(1)
        {
            NewLineCounter = 0;
            
            for(NewLineCounter = 0; FileData == '\n'; NewLineCounter++)
            {
                FileData = getc(fp);
                
                if(NewLineCounter < 2)
                    printf("\n");
            }
            
            if(FileData == EOF)
                break;
            
            printf("%c", FileData);
            
            FileData = getc(fp);
        }
    Now I need to re-add the if newline print "$" feature and detecting tabs now.

  14. #44
    Registered User
    Join Date
    Sep 2017
    Posts
    93
    Got everything working now. It seems that all I need to do is implement flag options.

    Code:
    #include <stdio.h>
    #include <string.h>
    #include <stdint.h>
    
    
    int main(int argc, const char * argv[])
    {
        int8_t FileData;
        uint64_t NewLineCounter, TabCounter;
        FILE *fp = NULL;
        
        if(argc != 2)
        {
            fprintf(stderr, "Please enter one file name.\n");
            return 1;
        }
        
        fp = fopen(argv[1], "r");
        
        if(fp == NULL)
        {
            fprintf(stderr, "No such file found.\n");
            return 1;
        }
        
        FileData = getc(fp);
        
        while(1)
        {
            for(NewLineCounter = 0; FileData == '\n'; NewLineCounter++)
            {
                if(NewLineCounter < 2)
                    printf("$\n");
                
                FileData = getc(fp);
            }
            
            for(TabCounter = 0; FileData == '\t'; TabCounter++)
            {
                printf("^I");
                
                FileData = getc(fp);
            }
            
            if(FileData == EOF)
                break;
            
            printf("%c", FileData);
            
            FileData = getc(fp);
        }
        
        fclose(fp);
        
        return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can someone give me an example of the following
    By Overworked_PhD in forum C Programming
    Replies: 11
    Last Post: 05-31-2009, 09:37 AM
  2. could you give me homework please
    By thestien in forum C++ Programming
    Replies: 14
    Last Post: 10-22-2006, 02:11 AM
  3. Replies: 1
    Last Post: 06-29-2004, 05:23 PM
  4. Why to give h e l p?
    By money? in forum A Brief History of Cprogramming.com
    Replies: 35
    Last Post: 08-04-2003, 08:15 PM
  5. I give up! can someone help me out please?
    By Marcos in forum C++ Programming
    Replies: 14
    Last Post: 01-30-2003, 08:41 PM

Tags for this Thread