From nelsoj07@csse.uwa.edu.au Tue Jul 28 16:20:46 2015 Date: Tue Jul 28 16:20:46 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.235.222 Subject: Study group From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: lightbulb.png X-img: none Hey everyone, would anyone be interested in forming a study group for this unit? As Chris said today, the projects are able to be done in pairs and I think this is a good way to meet other people doing the unit! The idea is that it would be a good way to sit down and go over the material covered that week or really anything that people want to go over in an informal setting. Reid Library collaborative area straight after one or both of the lectures might be a good idea, and if anyone's interested I'm happy to hang around for an hour or two to go over anything and get to know some of you! I'll be in the collaborative area from 4-6PM today and on Thursday too if anyone replies to this. Feel free to email me as well if you're keen and I'm happy to organise it! From chinnd01@csse.uwa.edu.au Wed Jul 29 09:55:36 2015 Date: Wed Jul 29 09:55:36 2015 To: help2002@csse.uwa.edu.au Received: from 120.145.131.131 Subject: Study group From: "David Chinnery" <21142701@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > Hey everyone, would anyone be interested in forming a study group for this unit? As > Chris said today, the projects are able to be done in pairs and I think this is a > good way to meet other people doing the unit! > > The idea is that it would be a good way to sit down and go over the material covered > that week or really anything that people want to go over in an informal setting. > Reid Library collaborative area straight after one or both of the lectures might be > a good idea, and if anyone's interested I'm happy to hang around for an hour or two > to go over anything and get to know some of you! I'll be in the collaborative area > from 4-6PM today and on Thursday too if anyone replies to this. > > Feel free to email me as well if you're keen and I'm happy to organise it! Hey Jake, Yeah I'm keen, but can't do it after either lecture. I'm free 13:00-15:00 Tues and all day up to our lecture on Thurs. If that suits?? Thanks Dave From nelsoj07@csse.uwa.edu.au Wed Jul 29 12:40:09 2015 Date: Wed Jul 29 12:40:09 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.235.222 Subject: Study group From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Awesome David, yeah I can do earlier on either day. Say Thursday at 1PM, collaborative area at the bottom of Reid? From chinnd01@csse.uwa.edu.au Wed Jul 29 12:46:25 2015 Date: Wed Jul 29 12:46:25 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.175.121 Subject: Study group From: "David Chinnery" <21142701@student.uwa.edu.au> X-smilie: none X-img: none Yeap done ! :) Thursday 1PM From 00043278@csse.uwa.edu.au Thu Jul 30 14:39:07 2015 Date: Thu Jul 30 14:39:07 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.80.20 Subject: ACM Inter-Collegiate Programming Competition From: "Timothy French" X-smilie: none X-img: none Hi all, We're looking for new people to join the competitive programming group at UWA. We have regular competitions with universities from Australia and New Zealand, and it's a great opportunity to improve your programming, learn advanced algorithms and solve fun problems. It's also a good way to get noticed by employers (e.g. about 10 students have gone from the programming comp to Google in recent years). The competitions are held on some Saturdays and students compete in teams of up to three. Students are given a set of algorithmic and programming problems, and have to complete as many as possible in 5 hours. The competition is run online, so you would be competing against some of the best student programmers in Australia and New Zealand. Also, the school of Computer Science and Software Engineering generously provides a pizza lunch for competitors. On August 22nd, there will be a Divisional Competition where teams will be competing for a place at the regional final, to be held in Auckland this year. We will also run training sessions this semester on Wednesdays at 5pm in room 2.28 in the computer science building. Here you can learn advanced algorithms and programming techniques, even if you’re not able to compete. If you’re interested in finding out more, come along to the next training session on August 5. You can find out more on the UWA ICPC forum: https://secure.csse.uwa.edu.au/run/icpcforum (you can sign up for email updates there if you’re interested, because I won’t be sending out any bulk emails after this one). Let me know if you have any questions, From maic04@csse.uwa.edu.au Fri Jul 31 17:30:46 2015 Date: Fri Jul 31 17:30:46 2015 Edit: Fri Jul 31 17:32:22 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.121.167 Subject: Study group From: "Vu Mai" <21296878@student.uwa.edu.au> X-smilie: none X-img: none I would also be interested in a study group if there are any more. From lopasb03@csse.uwa.edu.au Sat Aug 1 16:36:20 2015 Date: Sat Aug 1 16:36:20 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.88.216 Subject: Using VIM and accessing the lab computers remotely From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: bigsmile.png X-img: none Hi, I want to access the apple computers in the lab remotely so that I can work from home. Does anyone know the step-by-step process to connect to the lab computers? Any help would be appreciated. Cheers, Ben. From 00014979@csse.uwa.edu.au Sun Aug 2 13:10:24 2015 Date: Sun Aug 2 13:10:24 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.57.181 Subject: Echo360 recording of tutorials From: "Christopher McDonald" X-smilie: none X-img: none The first tutorial (Fri 31st July) appears not to have been recorded. The intention was/is for them to be recorded; I used the microphone, etc, but alas. I’ve asked the powers that be for next week and beyond. From 00014979@csse.uwa.edu.au Sun Aug 2 18:52:23 2015 Date: Sun Aug 2 18:52:23 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.57.181 Subject: Using VIM and accessing the lab computers remotely From: "Christopher McDonald" X-smilie: none X-img: none If logging in from home, or from your laptop, you cannot login to the machines in CSSE Lab 2.01 directly - you first need to log into a machine at the "edge" of the CSSE network, and from there login to a lab machine. If your home computer or laptop is running OS-X or Linux, then you can use the command-line command: ssh 20000001@uggp.csse.uwa.edu.au and authenticate using your UWA Pheme password. If your home computer or laptop is running Windows, your'll need a copy of a program named Putty. Download a copy from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html, then first connect to uggp.csse.uwa.edu.au with your UWA ID and Pheme password. The machine named uggp.csse.uwa.edu.au is running Linux (which may be what you want to use); if you want to use a CSSE lab machine, then you'll need to "find" one. Computers in CSSE Lab 2.01 boot into one of OS-X, Linux, or Windows and depending on their operating system they have a different name on the network. For example computer #5 in lab 2.01 may be named: ecm-csse2105-x ; if running OS-X ecm-csse2105-l ; if running Linux ecm-csse2105-w ; if running Windows So you can then try to access an OS-X computer with the command: ssh ecm-csse2101-x.uniwa.uwa.edu.au or ssh ecm-csse2102-x.uniwa.uwa.edu.au or ....... If you login to an OS-X machine from your home machine: Home -> uggp.csse.uwa.edu.au -> ecm-csse2101-x.uniwa.uwa.edu.au and then display your present working directory, with 'pwd' it'll indicate /Users/20000001, which is a copied-on-login directory of OS-X specific files, created when you login. Your UNIWA network home (what Windows mounts as your H: drive) will be mounted on /Volumes/20000001, so leaving files in/below there will make them persist across logins and visible from our 3 OS platforms. (I have no idea why this has been made so diffcult for us all!) From vijp01@csse.uwa.edu.au Mon Aug 3 00:06:42 2015 Date: Mon Aug 3 00:06:42 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.146.164 Subject: Using VIM for the first time From: "Pradyumn Vij" <21469477@student.uwa.edu.au> X-smilie: none X-img: none I found a well written blog post if you've never used VIM or used VIM and become frustrated with it. http://www.sitepoint.com/getting-started-vim/ In addition if you want to use VIM with a more modern text editor, just grab Notepad++ for your OS and install the plugin "Visimulator" which enables VIM text input From chinnd01@csse.uwa.edu.au Mon Aug 3 10:05:53 2015 Date: Mon Aug 3 10:05:53 2015 To: help2002@csse.uwa.edu.au Received: from 1.127.48.151 Subject: Study group From: "David Chinnery" <21142701@student.uwa.edu.au> X-smilie: none X-img: none "Vu Mai" <21296878@student.uwa.edu.au> wrote: > I would also be interested in a study group if there are any more. Yeah sure. We would normally meet at 13:00 Tuesday downstairs in the Reid colab area (we try to get near the smarter area). This week we are meeting today at 2,same place. Hopefully after this week it will be a regular thing on Tuesday. From nelsoj07@csse.uwa.edu.au Mon Aug 3 10:21:41 2015 Date: Mon Aug 3 10:21:41 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.235.222 Subject: Study group From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Hey Vu, Yep I'm hoping that these will be on each week of semester if there's still interest. David and I are meeting at 2PM today at the StudySmarter desks in Collab at the bottom of Reid library if you can join, but I'll also be at the StudySmarter desks from 1PM to 3PM Tuesday and Thursday this week as well, and then from next week will aim to settle into a regular schedule. I don't mind being there twice a week either way. Please add yourself to the group on Facebook here to make it easier to organise: https://www.facebook.com/groups/1647695805467074/members/ Thanks! From lis63@csse.uwa.edu.au Mon Aug 3 11:12:02 2015 Date: Mon Aug 3 11:12:02 2015 To: help2002@csse.uwa.edu.au Received: from 180.216.42.56 Subject: Study group From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none Hi, I am also interested in the study group. Can I join you? I have added myself to the facebook group. From nelsoj07@csse.uwa.edu.au Mon Aug 3 11:18:28 2015 Date: Mon Aug 3 11:18:28 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.235.222 Subject: Study group From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Of course, just accepted the request! Feel free to meet us this afternoon or tomorrow :) From 00014979@csse.uwa.edu.au Mon Aug 3 14:01:20 2015 Date: Mon Aug 3 14:01:20 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Using VIM for the first time From: "Christopher McDonald" X-smilie: none X-img: none "Pradyumn Vij" <21469477@student.uwa.edu.au> wrote: > In addition if you want to use VIM with a more modern text editor, just grab Notepad++ > for your OS and install the plugin "Visimulator" which enables VIM text input You (everyone) will have their own preferences about what a modern text editor needs to provide, but you can also get gvim to run natively on Windows: http://www.vim.org/download.php#pc From graven01@csse.uwa.edu.au Mon Aug 3 16:54:28 2015 Date: Mon Aug 3 16:54:28 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Using VIM and accessing the lab computers remotely From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none Just curious as to why this would be necessary, whats on the lab computers that we cannot get on out home pc/mac? i'm assuming we can do all the lab work from home anyway and it more of a supervised session if we need the assistance? From 00014979@csse.uwa.edu.au Tue Aug 4 07:38:50 2015 Date: Tue Aug 4 07:38:50 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.57.181 Subject: Using VIM and accessing the lab computers remotely From: "Christopher McDonald" X-smilie: none X-img: none Maybe not *necessary*, but good to know. Not all students will have either Linux or OS-X at home or on their laptops, or just have one, and may be keen to ensure that their programs are portable across different operating systems. Moreover, the 2 projects will be marked on OS-X, so it's a very good idea to ensure that your projects work there before submitting them. And an hour before a deadline is not the best time to discover that your project doesn't work as you thought. It's also best not think of the laboratory exercises and projects as just things that "have to be done", but opportunities to learn more about contemporary computer systems. It's difficult to learn much about a new system or language just by sitting in front of it - you need an exercise or goal to complete to force you to learn new things. From lopasb03@csse.uwa.edu.au Tue Aug 4 17:15:34 2015 Date: Tue Aug 4 17:15:34 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.202.173 Subject: Using VIM and accessing the lab computers remotely From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: insane.png X-img: none Hi Chris, I am using "code::blocks", which is a cross platform IDE for many languages including C. I am a bit confused about wether the code I write in this program will work on an OS-X operating system (I am using windows). I thought it should, because it is cross platform? Or do I have to use putty and connect to an OS-X machine to effectively test whether my code works? From bradfj01@csse.uwa.edu.au Tue Aug 4 18:49:10 2015 Date: Tue Aug 4 18:49:10 2015 To: help2002@csse.uwa.edu.au Received: from 60.224.9.24 Subject: Lecture recording? From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none Just wondering if Tuesday's lecture was recorded as it is not in LCS. Thnak you :) From bradfj01@csse.uwa.edu.au Tue Aug 4 19:09:54 2015 Date: Tue Aug 4 19:09:54 2015 To: help2002@csse.uwa.edu.au Received: from 60.224.9.24 Subject: Lecture recording? From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none Wait, it has been uploaded. Sorry for the kerfuffle. From 00014979@csse.uwa.edu.au Wed Aug 5 04:41:05 2015 Date: Wed Aug 5 04:41:05 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.57.181 Subject: Using VIM and accessing the lab computers remotely From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hi Chris, > > I am using "code::blocks", which is a cross platform IDE for many languages including C. I am a bit > confused about wether the code I write in this program will work on an OS-X operating system > (I am using windows). I thought it should, because it is cross platform? Or do I have to use putty > and connect to an OS-X machine to effectively test whether my code works? Hello Anonymous, code::blocks is a good environment, however its description as being 'cross platform' means that the code::blocks program *itself* can be built and run on more than one platform (and not necessarily more than 2). So while c::b is cross platform, that doesn't mean that any programs that your enter and develop in c::b will be, themselves, be cross platform. C programs, if written well, can be portable at their source-code level - meaning that if you copy their source from one platform to another, and recompile, then they can run and produce the same results on that second platform. However, no IDE will do this automatically for you. For example, the following small (safe) program compiles and runs perfectly on OS-X and Linux, but not on Windows (unless the Windows platform has some 3rd-party libraries installed). No IDE can correct for the differences: #include int main(void) { fork(); } From lopasb03@csse.uwa.edu.au Wed Aug 5 06:12:07 2015 Date: Wed Aug 5 06:12:07 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.202.173 Subject: Using VIM and accessing the lab computers remotely From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: laugh.png X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > Hi Chris, > > > > I am using "code::blocks", which is a cross platform IDE for many languages including C. I am a bit > > confused about wether the code I write in this program will work on an OS-X operating system > > (I am using windows). I thought it should, because it is cross platform? Or do I have to use putty > > and connect to an OS-X machine to effectively test whether my code works? > > Hello Anonymous, > > code::blocks is a good environment, however its description as being 'cross platform' means that the > code::blocks program *itself* can be built and run on more than one platform (and not necessarily more than > 2). So while c::b is cross platform, that doesn't mean that any programs that your enter and develop in c::b > will be, themselves, be cross platform. > > C programs, if written well, can be portable at their source-code level - meaning that if you copy their > source from one platform to another, and recompile, then they can run and produce the same results on that > second platform. However, no IDE will do this automatically for you. > > For example, the following small (safe) program compiles and runs perfectly on OS-X and Linux, but not on > Windows (unless the Windows platform has some 3rd-party libraries installed). No IDE can correct for the > differences: > > #include > > int main(void) > { > fork(); > } Thanks Chris, that answered my question perfectly. :) From bullof01@csse.uwa.edu.au Thu Aug 6 15:48:10 2015 Date: Thu Aug 6 15:48:10 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.186.32 Subject: Solution to question in lect about args From: "Fraser Bullock" <21299527@student.uwa.edu.au> X-smilie: verycool.png X-img: none when you enter the command line code to run the program, in the background the system tries to call the function "main", passing on the parameters to the function of 1. the count of arguments passed in the commandline and 2. an array of char arrays of each argument passed. int main(int argc, char *argv[]) as you can see, the first variable, argc, is simply the count of how many elements are in the argv array, where each element of the argv array are char arrays (Strings) of the command line call. so if we had a command line call like: ./rot foo bar then the parameters passed to the main function would be: argc => 3 argv => ["rot", "foo", "bar"] or, more realistically: argv => [ ['r', 'o', 't'], ['f', 'o', 'o'], ['b', 'a', 'r'] ] most of the spicy steps of the lab require you to understand this. more examples: ./rot tomato 5 banana 15 potato.txt argc => 6 argv => [['r','o','t'], ['t','o','m','a','t',o''], ['5'], ['b','a','n','a','n', 'a'], ['1','5'], ['p','o','t','a','t','o','.','t','x','t']] why do all this? this is what allows you to quickly and easily tell a program what you specifically want it to do without having to recompile it or write code to load in a file with this data in it. keep in mind that a program doesn't have to do this, you could just ignore it. Also note that argc and argv are arbitrary variable names that has been used, you can call them what ever you want. (argumentCount, argumentValues, ac, av... etc) Hopefully this answers this question, lemme know if there's something you didn't get. From armstc06@csse.uwa.edu.au Sat Aug 8 04:17:49 2015 Date: Sat Aug 8 04:17:49 2015 To: help2002@csse.uwa.edu.au Received: from 220.233.26.225 Subject: void From: "Cameron Armstrong" <21194619@student.uwa.edu.au> X-smilie: bigkiss.png X-img: none I've seen a lot of C programs that have void in the parameters instead of having empty brackets. E.g. int main(void) {}. Is there any specific reason to do this as opposed to just leaving the brackets empty? I don't see this done in any other programming languages I have encountered. The C Primer book I have mentions this void being introduced in C99 but didn't explain why it was. I saw you typing it in the cal program so it must serve some purpose. From 00014979@csse.uwa.edu.au Sat Aug 8 07:06:59 2015 Date: Sat Aug 8 07:06:59 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.57.181 Subject: void From: "Christopher McDonald" X-smilie: none X-img: none A good question. If, for example, we declare a function as: int banana(); it states that banana is a function, but that we don't know how many, or what type, of arguments it expects. Consequently the compiler can't provide any assistance when you call banana with zero, one, or six arguments - it's unknown if any of the calls are correct, or incorrect (in fact all of them could be correct, if we knew that the function accepted a variable number of arguments). If we declare a function as: int banana(int, char); we (the compiler) knows that the function must be called with exactly two arguments, an int and a char, in that order. If we declare a function as: int banana(void); we know that the function must be called with zero arguments, as banana expects none. Declaring a function as: int banana(); is an unsafe practice. From 00014979@csse.uwa.edu.au Sat Aug 8 07:08:43 2015 Date: Sat Aug 8 07:08:43 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.57.181 Subject: Echo360 recording of tutorials From: "Christopher McDonald" X-smilie: none X-img: none Yesterday's (2nd) tutorial has been uploaded, so it looks like it'll keep happening. The solution that we developed, yesterday, has also been linked via our Schedule page. From 00014979@csse.uwa.edu.au Sat Aug 8 07:10:07 2015 Date: Sat Aug 8 07:10:07 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.57.181 Subject: Labsheet 1 sample solutions From: "Christopher McDonald" X-smilie: none X-img: none Some sample solutions for the basic questions on Labsheet 1 are now available via our Schedule page. The tutorial solution that we developed yesterday, has also been linked via our Schedule page. From tans121@csse.uwa.edu.au Sat Aug 8 16:10:03 2015 Date: Sat Aug 8 16:10:03 2015 To: help2002@csse.uwa.edu.au Received: from 122.111.231.6 Subject: Solution to question in lect about args From: "Shao-Ming Tan" <20920822@student.uwa.edu.au> X-smilie: none X-img: none So the first two variables of main will always be the number of arguments and the argument values? main( number_of_variables, argument vectors) Also, why is there a * before argv[] and not just argv? "Fraser Bullock" <21299527@student.uwa.edu.au> wrote: > when you enter the command line code to run the program, in the background the > system tries to call the function "main", passing on the parameters to the > function of 1. the count of arguments passed in the commandline and 2. an array > of char arrays of each argument passed. > > int main(int argc, char *argv[]) > > as you can see, the first variable, argc, is simply the count of how many > elements are in the argv array, where each element of the argv array are char > arrays (Strings) of the command line call. > > so if we had a command line call like: > ./rot foo bar > > then the parameters passed to the main function would be: > argc => 3 > argv => ["rot", "foo", "bar"] > > or, more realistically: > argv => [ ['r', 'o', 't'], ['f', 'o', 'o'], ['b', 'a', 'r'] ] > > most of the spicy steps of the lab require you to understand this. > > more examples: > ./rot tomato 5 banana 15 potato.txt > argc => 6 > argv => [['r','o','t'], ['t','o','m','a','t',o''], ['5'], ['b','a','n','a','n', > 'a'], ['1','5'], ['p','o','t','a','t','o','.','t','x','t']] > > why do all this? this is what allows you to quickly and easily tell a program > what you specifically want it to do without having to recompile it or write code > to load in a file with this data in it. keep in mind that a program doesn't have > to do this, you could just ignore it. > > Also note that argc and argv are arbitrary variable names that has been used, you > can call them what ever you want. (argumentCount, argumentValues, ac, av... etc) > > Hopefully this answers this question, lemme know if there's something you didn't > get. From fetzee01@csse.uwa.edu.au Sat Aug 8 18:17:51 2015 Date: Sat Aug 8 18:17:51 2015 Edit: Sat Aug 8 18:18:51 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.162.188 Subject: Solution to question in lect about args From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none http://www.catb.org/~esr/faqs/smart-questions.html#stackoverflow From jennib03@csse.uwa.edu.au Sat Aug 8 19:25:14 2015 Date: Sat Aug 8 19:25:14 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.226.68 Subject: Using VIM for the first time From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none "Pradyumn Vij" <21469477@student.uwa.edu.au> wrote: > http://www.sitepoint.com/getting-started-vim/ I had a play with ed, which is referred to in the link you provided Prad. I actually kind of like its bare bone approach. :) Now if only it could have line numbers and syntax highlighting on the outputs... hehe. From armstc06@csse.uwa.edu.au Sat Aug 8 21:03:39 2015 Date: Sat Aug 8 21:03:39 2015 To: help2002@csse.uwa.edu.au Received: from 220.233.26.225 Subject: void From: "Cameron Armstrong" <21194619@student.uwa.edu.au> X-smilie: none X-img: none Thank you. I understand now. I'm guessing other languages use compilers that are smarter than the C compiler because for example in Objective-C, C#, etc you don't even need to declare a method before using it. You can just define it and use it immediately. From 00014979@csse.uwa.edu.au Sun Aug 9 18:16:00 2015 Date: Sun Aug 9 18:16:00 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.57.181 Subject: void From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Thank you. I understand now. I'm guessing other languages use compilers that are smarter than the C > compiler because for example in Objective-C, C#, etc you don't even need to declare a method before > using it. You can just define it and use it immediately. It's not so much about compilers being smarter, but about languages' history and design driving what compilers are required to do. C evolved in an era of low memory and limited power hardware (and still excels in those environments). Because of this, the language requires that full details about any symbol (is it a function? what type parameters does it take? what is the data type of function's returned value?) must be known before it is used. This enables a C compiler to do all of its work in a single pass of the source code, whereas languages that permit symbols to be used before they are fully known require multi-pass compilers. This means that we usually see C's main() function at the bottom of its source file, so everything it needs to know about is above it, and details of all functions (both internal and external) declared before use (and their declarations may be 'hidden' in header files). [Also, careful with your use of the words 'declare' and 'define' - to declare means to only provide details of the existence of a symbol, and to define means to actually specify the memory or code for it] From armstc06@csse.uwa.edu.au Mon Aug 10 01:55:36 2015 Date: Mon Aug 10 01:55:36 2015 To: help2002@csse.uwa.edu.au Received: from 220.233.26.225 Subject: void From: "Cameron Armstrong" <21194619@student.uwa.edu.au> X-smilie: none X-img: none Thank you very much. Very informative. "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > Thank you. I understand now. I'm guessing other languages use compilers that are smarter than the C > > compiler because for example in Objective-C, C#, etc you don't even need to declare a method before > > using it. You can just define it and use it immediately. > > It's not so much about compilers being smarter, but about languages' history and design driving what compilers > are required to do. > > C evolved in an era of low memory and limited power hardware (and still excels in those environments). Because > of this, the language requires that full details about any symbol (is it a function? what type parameters does > it take? what is the data type of function's returned value?) must be known before it is used. This enables a C > compiler to do all of its work in a single pass of the source code, whereas languages that permit symbols to be > used before they are fully known require multi-pass compilers. > > This means that we usually see C's main() function at the bottom of its source file, so everything it > needs to know about is above it, and details of all functions (both internal and external) declared before use > (and their declarations may be 'hidden' in header files). > > [Also, careful with your use of the words 'declare' and 'define' - to declare means to only provide details of > the existence of a symbol, and to define means to actually specify the memory or code for it] From soarec01@csse.uwa.edu.au Tue Aug 11 18:15:23 2015 Date: Tue Aug 11 18:15:23 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.153.67 Subject: Running linux inside a windows platform. From: "Christopher Soares" <21329621@student.uwa.edu.au> X-smilie: none X-img: none Has anyone successfully been using a virtual machine to run a linux system inside of their windows PC? I tried using Linux Live (lili) which is supposed to run a linux based operating system from a USB thumb drive, but I didn't have any luck in getting it to work. I like the thumb drive based virtual machine idea since it can run inside windows and doesn't require re-boot or partitioning of my disk. From armstc06@csse.uwa.edu.au Wed Aug 12 07:42:24 2015 Date: Wed Aug 12 07:42:24 2015 To: help2002@csse.uwa.edu.au Received: from 220.233.26.225 Subject: Running linux inside a windows platform. From: "Cameron Armstrong" <21194619@student.uwa.edu.au> X-smilie: none X-img: none For virtualisation in windows I use VMware Player which is free from here https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/7_0 Download the windows version of that, then download any Linux distribution of your choice (I am fond of Ububtu) and the. You can install to that virtual machine From porebm01@csse.uwa.edu.au Wed Aug 12 12:28:52 2015 Date: Wed Aug 12 12:28:52 2015 To: help2002@csse.uwa.edu.au Received: from 121.215.128.134 Subject: Use of modulus, % operator From: "Martin Porebski" <21498791@student.uwa.edu.au> X-smilie: none X-img: none Hi, I understand that the % operator yields the division remainder but I'm not exactly clear on how and why it is used. For example why was it used in LAB 01 ('a' + (c - 'a' + ROT) % 26) From 00014979@csse.uwa.edu.au Wed Aug 12 13:53:43 2015 Date: Wed Aug 12 13:53:43 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Use of modulus, % operator From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hi, > I understand that the % operator yields the division remainder but I'm not exactly > clear on how and why it is used. We use the modulus operator anytime we need the remainder (sorry). For example, imagine that we have an integer number of cents, and we'd like to print them out as dollars and cents: printf( "$%i.%02i\n", cents / 100, cents % 100); > For example why was it used in LAB 01 > ('a' + (c - 'a' + ROT) % 26) The modulus operator has the same precedence/priority as multiplication and division, all of which are higher than addition and subtraction: https://www.mathsisfun.com/operation-order-bodmas.html So the expression, above, is really: 'a' + ((c - 'a' + ROT) % 26) We evaluate the inner brackets first, to determine how far a character is after 'a', add to that our ROT value, which may send the sum 'past' the character 'z', and then use modulus to bring the result back into the range 0..25. We finally add the character 'a' to that value, resulting in characters between 'a' and 'z', inclusive. As above, we commonly use the modulus operator as (x % N) to bring a value back 'into the range' from 0..(N-1). Consider the following short code, which we can use to simulate the rolling of a die (one dice!), and writing the numeric face values from 1..6 : #include #include int main(void) { for(int i=0 ; i<10 ; ++i) { printf("%i\n", rand() % 6 + 1); } return 0; } From chowda01@csse.uwa.edu.au Wed Aug 12 15:19:08 2015 Date: Wed Aug 12 15:19:08 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.112.22 Subject: Running and editing C programs from the terminal From: "Anirban Chowdhury" <21432966@student.uwa.edu.au> X-smilie: none X-img: none Hi, i am confused about how to run and edit a particular c program from the terminal. Any help would be greatly appreciated. Thanks.. From 00014979@csse.uwa.edu.au Wed Aug 12 16:28:40 2015 Date: Wed Aug 12 16:28:40 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Running and editing C programs from the terminal From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hi, i am confused about how to run and edit a particular c program from the terminal. > > Any help would be greatly appreciated. > Thanks.. Have you been following the information provided on our Schedule webpage (the 3rd column), for Week-2 (Mon 3rd August) ? From chowda01@csse.uwa.edu.au Wed Aug 12 17:01:59 2015 Date: Wed Aug 12 17:01:59 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.112.22 Subject: Running and editing C programs from the terminal From: "Anirban Chowdhury" <21432966@student.uwa.edu.au> X-smilie: none X-img: none Oh alright got it now. Thanks a lot. From porebm01@csse.uwa.edu.au Wed Aug 12 17:51:36 2015 Date: Wed Aug 12 17:51:36 2015 To: help2002@csse.uwa.edu.au Received: from 121.215.128.134 Subject: Use of modulus, % operator From: "Martin Porebski" <21498791@student.uwa.edu.au> X-smilie: none X-img: none Thanks :) From porebm01@csse.uwa.edu.au Wed Aug 12 17:52:58 2015 Date: Wed Aug 12 17:52:58 2015 To: help2002@csse.uwa.edu.au Received: from 121.215.128.134 Subject: Running linux inside a windows platform. From: "Martin Porebski" <21498791@student.uwa.edu.au> X-smilie: none X-img: none You can also use Windows Server to run the linux server/os From nelsoj07@csse.uwa.edu.au Wed Aug 12 21:22:19 2015 Date: Wed Aug 12 21:22:19 2015 To: help2002@csse.uwa.edu.au Received: from 121.215.140.117 Subject: Using VIM for the first time From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: lightbulb.png X-img: none "Benjamin Jennings" <21460003@student.uwa.edu.au> wrote: > "Pradyumn Vij" <21469477@student.uwa.edu.au> wrote: > > > http://www.sitepoint.com/getting-started-vim/ > > I had a play with ed, which is referred to in the link you provided Prad. I actually kind of like > its bare bone approach. :) > > Now if only it could have line numbers and syntax highlighting on the outputs... hehe. It can! Try > vim ~/.vimrc And then add the lines syntax enable set nu Then save and exit, should provide syntax highlighting and line numbers for you! You might need to turn the setting to display ANSI color on if you're using Terminal on a Mac. From bradfj01@csse.uwa.edu.au Thu Aug 13 18:10:47 2015 Date: Thu Aug 13 18:10:47 2015 To: help2002@csse.uwa.edu.au Received: from 60.224.9.24 Subject: puTTy From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none Hi all, I was interested in the previous article regarding connecting to the Lab Computers through puTTy. I have logged into a machine and from my home machine connected successfully. However, now that I am home I cannot connect to it. Am I doing something so obviously wrong. From chinnd01@csse.uwa.edu.au Thu Aug 13 19:43:07 2015 Date: Thu Aug 13 19:43:07 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.175.16 Subject: puTTy From: "David Chinnery" <21142701@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > Hi all, > > I was interested in the previous article regarding connecting to the Lab Computers > through puTTy. I have logged into a machine and from my home machine connected > successfully. However, now that I am home I cannot connect to it. Am I doing > something so obviously wrong. Hi Anon Have you first set up a VPN connection? http://www.bits.uwa.edu.au/it-help/access/uniconnect/connecting Dave From vijp01@csse.uwa.edu.au Fri Aug 14 17:09:52 2015 Date: Fri Aug 14 17:09:52 2015 To: help2002@csse.uwa.edu.au Received: from 220.253.137.121 Subject: Running linux inside a windows platform. From: "Pradyumn Vij" <21469477@student.uwa.edu.au> X-smilie: none X-img: none Oracle's VirutalBox is another really easy method that is used by many people. https://www.virtualbox.org/ From vijp01@csse.uwa.edu.au Fri Aug 14 17:14:39 2015 Date: Fri Aug 14 17:14:39 2015 To: help2002@csse.uwa.edu.au Received: from 220.253.137.121 Subject: Using VIM for the first time From: "Pradyumn Vij" <21469477@student.uwa.edu.au> X-smilie: none X-img: none Also works best if you swap the binds of escape with capslock, this way your fingers don't leave the typing position to get into command mode. Having this minor change allowed me to more easily move around code. From lopasb03@csse.uwa.edu.au Sat Aug 15 14:05:29 2015 Date: Sat Aug 15 14:05:29 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.86.194 Subject: Using VIM and accessing the lab computers remotely From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: rolleyes.png X-img: none ANONYMOUS wrote: > "Christopher McDonald" wrote: > > > ANONYMOUS wrote: > > > > > Hi Chris, > > > > > > I am using "code::blocks", which is a cross platform IDE for many languages including C. I am a bit > > > confused about wether the code I write in this program will work on an OS-X operating system > > > (I am using windows). I thought it should, because it is cross platform? Or do I have to use putty > > > and connect to an OS-X machine to effectively test whether my code works? > > > > Hello Anonymous, > > > > code::blocks is a good environment, however its description as being 'cross platform' means that the > > code::blocks program *itself* can be built and run on more than one platform (and not necessarily more than > > 2). So while c::b is cross platform, that doesn't mean that any programs that your enter and develop in c::b > > will be, themselves, be cross platform. > > > > C programs, if written well, can be portable at their source-code level - meaning that if you copy their > > source from one platform to another, and recompile, then they can run and produce the same results on that > > second platform. However, no IDE will do this automatically for you. > > > > For example, the following small (safe) program compiles and runs perfectly on OS-X and Linux, but not on > > Windows (unless the Windows platform has some 3rd-party libraries installed). No IDE can correct for the > > differences: > > > > #include > > > > int main(void) > > { > > fork(); > > } > > Thanks Chris, that answered my question perfectly. :) Hi Chris, I have a question about using puTTy to connect to the lab computers. I tried to compile rot.c using the line: cc -std=c99 -Wall -Werror -pedantic -o rot rot.c At the prompt, however the computer complains with the following error: rot.c:1:1: error: ISO C requires a translation unit to contain at least one declaration [-Werror,-Wempty-translation-unit] I think I copied the instructions correctly, is there something I may be missing, can you fill me in on where I am going wrong? Thanks. c",) From chowda01@csse.uwa.edu.au Sat Aug 15 16:42:37 2015 Date: Sat Aug 15 16:42:37 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.112.22 Subject: Overloading main function From: "Anirban Chowdhury" <21432966@student.uwa.edu.au> X-smilie: none X-img: none I was just wondering if it is possible to overload the main function. thanks in advance. From 00014979@csse.uwa.edu.au Sat Aug 15 18:48:38 2015 Date: Sat Aug 15 18:48:38 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Overloading main function From: "Christopher McDonald" X-smilie: none X-img: none Not really (not in the sense of some O-O languages which permit method overloading). There are exactly 2 ways to define main(): - int main(void); - int main(int argc, char *argv[]); and you'll sometimes see: - int main(int argc, char *argv[], char *envp[]); used on some Unix systems, but it's not official or portable. Why do you wish to overload main()? From 00014979@csse.uwa.edu.au Sat Aug 15 18:50:25 2015 Date: Sat Aug 15 18:50:25 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Using VIM and accessing the lab computers remotely From: "Christopher McDonald" X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > At the prompt, however the computer complains with the following error: > > rot.c:1:1: error: ISO C requires a translation unit to contain at least one > declaration [-Werror,-Wempty-translation-unit] Not really enough information to go on, but it sounds like your C source file, rot.c, doesn't look at all like a C source file (from its very first character). From chowda01@csse.uwa.edu.au Sat Aug 15 21:54:19 2015 Date: Sat Aug 15 21:54:19 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.112.22 Subject: Overloading main function From: "Anirban Chowdhury" <21432966@student.uwa.edu.au> X-smilie: none X-img: none I was trying to write a method that would take as an argument a NUMBER OR a TEXT. Because of the OR factor i was thinking of writing 2 mains one with a NUMBER as an argument and another with TEXT as an argument. It would depend on the user which one he/she would select. I hope i made my question clear. Thanks From chowda01@csse.uwa.edu.au Sat Aug 15 22:50:11 2015 Date: Sat Aug 15 22:50:11 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.112.22 Subject: Is the Command line argument text or number? From: "Anirban Chowdhury" <21432966@student.uwa.edu.au> X-smilie: none X-img: none Is there any way i can figure out whether the command line argument provided is a text or a number? This is basically intended to help me answer question 8 of lab worksheet1. Thanks From 00014979@csse.uwa.edu.au Sun Aug 16 04:41:45 2015 Date: Sun Aug 16 04:41:45 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Overloading main function From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > I was trying to write a method that would take as an argument a NUMBER OR a TEXT. > > Because of the OR factor i was thinking of writing 2 mains one with a NUMBER as an argument and > another with TEXT as an argument. It would depend on the user which one he/she would select. > I hope i made my question clear. All command-line options are strings of characters, this is the single mechanism by which the OS passes information (including the program's name) to the program. If your program wishes to *interpret* an argument as a number, then you really only want your program to do that when, and where it wants - the OS can't know whether "123", "123x", or "three" should be interpreted as number by your program. You can check if the leading character of a string is a digit: if(isdigit(argv[1][0]) ..... or you can just assume that an string can be converted to an integer, and then use i = atoi(argv[1]); We warned that atoi("banana") will return zero, but the much more pedantic function strtol() can be used if this really matters. From 00014979@csse.uwa.edu.au Sun Aug 16 04:44:34 2015 Date: Sun Aug 16 04:44:34 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Is the Command line argument text or number? From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Is there any way i can figure out whether the command line argument provided is a text or a > number? This is basically intended to help me answer question 8 of lab worksheet1. All command-line arguments are strings of characters; if your program needs to *interpret* a string as something representing a number/integer, then your program needs to first convert it. From soarec01@csse.uwa.edu.au Sun Aug 16 23:26:39 2015 Date: Sun Aug 16 23:26:39 2015 To: help2002@csse.uwa.edu.au Received: from 114.30.99.75 Subject: Running linux inside a windows platform. From: "Christopher Soares" <21329621@student.uwa.edu.au> X-smilie: none X-img: none I ended up making a bootable linux USB drive using this software: http://www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/ It seems to work well. From 00014979@csse.uwa.edu.au Mon Aug 17 12:46:12 2015 Date: Mon Aug 17 12:46:12 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: (just for fun) The Underhanded C Contest From: "Christopher McDonald" X-smilie: none X-img: none The Underhanded C Contest today announced their eighth annual challenge. This is a competition that challenges coders to solve a simple data processing problem by writing innocent-looking C code that is as readable, clear, and seemingly trustworthy as possible, yet covertly implements a malicious function In many ways this is the exact opposite of the Obfuscated C Code Contest. The main goal of this contest is to write source code that is straightforward and easily passes visual inspection by other programmers, but implements some specific underhanded behaviour that cannot be easily detected. http://www.underhanded-c.org/ From luj20@csse.uwa.edu.au Mon Aug 17 22:57:43 2015 Date: Mon Aug 17 22:57:43 2015 To: help2002@csse.uwa.edu.au Received: from 110.175.130.7 Subject: Running linux inside a windows platform. From: "Juan Lu" <21691401@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > Has anyone successfully been using a virtual machine to run a linux system inside of > their windows PC? I tried using Linux Live (lili) which is supposed to run a linux > based operating system from a USB thumb drive, but I didn't have any luck in getting > it to work. > I like the thumb drive based virtual machine idea since it can run inside windows and > doesn't require re-boot or partitioning of my disk. I tried this website. It provides ubuntu online. https://pro.nitrous.io/app/#/containers/new From lopasb03@csse.uwa.edu.au Tue Aug 18 11:29:26 2015 Date: Tue Aug 18 11:29:26 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.171.115 Subject: Using VIM and accessing the lab computers remotely From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: verytired.png X-img: none "Christopher McDonald" wrote: > "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > > > At the prompt, however the computer complains with the following error: > > > > rot.c:1:1: error: ISO C requires a translation unit to contain at least one > > declaration [-Werror,-Wempty-translation-unit] > > > Not really enough information to go on, but it sounds like your C source file, rot.c, > doesn't look at all like a C source file (from its very first character). OK, so I just bought an iMac G5, so I can definitely do the work in my own time. However, I still get an error when I try to compile rot.c from the first lab. When I type "cc -std=c99 -Wall -Werror -pedantic -o rot rot.c" I get the following error "-bash: /usr/bin/cc: Bad CPU type in executable" What am I missing now, I thought it would be cake from here on out? From 00014979@csse.uwa.edu.au Tue Aug 18 11:37:07 2015 Date: Tue Aug 18 11:37:07 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Using VIM and accessing the lab computers remotely From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > > OK, so I just bought an iMac G5, so I can definitely do the work in my own time. However, I > still get an error when I try to compile rot.c from the first lab. > > When I type "cc -std=c99 -Wall -Werror -pedantic -o rot rot.c" > > I get the following error "-bash: /usr/bin/cc: Bad CPU type in executable" > > What am I missing now, I thought it would be cake from here on out? I sincerely hope that you didn't pay too much for the G5 if it was purchased just for this unit. Apple shifted their product line to the Intel architecture in 2005 (first with OS-X Tiger), and has effectively abandoned the G5 architecture since then. It's incompatible with contemporary Apple platforms and software, and that's what the error message is effectively saying, if you've just copied another C compiler onto your G5. From lopasb03@csse.uwa.edu.au Tue Aug 18 11:44:34 2015 Date: Tue Aug 18 11:44:34 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.171.115 Subject: Using VIM and accessing the lab computers remotely From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Its an older G5, 2006 I think, with Mac OS X 10.6.8 , I thought if I get one that is in between 1999 and 2011, it should most definitely have a c99 compiler, was I wrong? Is there anything I can do to fix the error? From 00014979@csse.uwa.edu.au Tue Aug 18 11:57:04 2015 Date: Tue Aug 18 11:57:04 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Using VIM and accessing the lab computers remotely From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Its an older G5, 2006 I think, with Mac OS X 10.6.8 , I thought if I get one that is in between 1999 and 2011, it > should most definitely have a c99 compiler, was I wrong? Is there anything I can do to fix the error? Are you sure? Most websites are saying that the last PowerPC G5s can only be upgraded to 10.5.8 The G5 is *hardware* incompatible with the Intel architecture, though you may be right if you're able to find/collect all necessary software for the G5 (though from 3rd parties, as Apple quickly deprecates most things older than one-version before the current one). I'm afraid that I don't have enough info. to diagnose that error msg. From lopasb03@csse.uwa.edu.au Tue Aug 18 12:12:19 2015 Date: Tue Aug 18 12:12:19 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.171.115 Subject: Using VIM and accessing the lab computers remotely From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Which lab sessions do you run this week Chris? Can I bring in my iMac so you can have a look? From 00014979@csse.uwa.edu.au Tue Aug 18 13:11:34 2015 Date: Tue Aug 18 13:11:34 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Using VIM and accessing the lab computers remotely From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Which lab sessions do you run this week Chris? Can I bring in my iMac so you can have a look? Wednesday morning from 9am. It's not really a "service" provided for unit, so I'll have to give priority to any other students asking questions about the labsheet. From lopasb03@csse.uwa.edu.au Wed Aug 19 10:37:03 2015 Date: Wed Aug 19 10:37:03 2015 Edit: Wed Aug 19 10:37:33 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.178.183 Subject: Using VIM and accessing the lab computers remotely From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > Which lab sessions do you run this week Chris? Can I bring in my iMac so you can have a look? > > Wednesday morning from 9am. > It's not really a "service" provided for unit, so I'll have to give priority to any other students asking > questions about the labsheet. Thanks for the help Chris I managed to figure it out, I just had to install Xcode 3.2.6 which is compatible with Snow Leopard 10.6.8, so after I installed it everything worked fine; However, to compile I have to write 'gcc' instead of 'cc'. Cheers, Ben. c",) From 00014979@csse.uwa.edu.au Wed Aug 19 11:37:16 2015 Date: Wed Aug 19 11:37:16 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Using VIM and accessing the lab computers remotely From: "Christopher McDonald" X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > Thanks for the help Chris I managed to figure it out, I just had to install Xcode 3.2.6 which is compatible > with Snow Leopard 10.6.8, so after I installed it everything worked fine; However, to compile I have to write > 'gcc' instead of 'cc'. Cheers, Ben. c",) Glad you got it working; incidentally, what version of the OS do you have running on the G5? From 00014979@csse.uwa.edu.au Wed Aug 19 11:39:11 2015 Date: Wed Aug 19 11:39:11 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: How much RAM for a desktop machine? From: "Christopher McDonald" X-smilie: none X-img: none An article receiving attention, today: http://www.techspot.com/article/1043-8gb-vs-16gb-ram/ How Much RAM? 4GB vs. 8GB vs. 16GB Performance and many Slashdot comments: http://hardware.slashdot.org/story/15/08/18/1745239/revisiting-how-much-ram-is-enough-today-for-desktop-computing From lopasb03@csse.uwa.edu.au Wed Aug 19 12:37:40 2015 Date: Wed Aug 19 12:37:40 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.221 Subject: Using VIM and accessing the lab computers remotely From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none The model is iMac4,1 It now has Developer version 3.2, when I click on Mac information it says it is still running Mac OS X 10.6.8; However, when I search the Developer info it says it has mac OS X SDKs 10.4, 10.5 and 10.6 . Not sure exactly if that is helpful, but I have tested a few other programs and it appears to be running the same C compiler as the lab computers. ps. I only had to spend $150 to buy the computer. c",) From newmal01@csse.uwa.edu.au Wed Aug 19 16:45:43 2015 Date: Wed Aug 19 16:45:43 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.140 Subject: Project 1 From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none Hi i was just wondering when the project 1 will be available From newmal01@csse.uwa.edu.au Wed Aug 19 16:46:06 2015 Date: Wed Aug 19 16:46:06 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.140 Subject: Project 1 partner From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none hey is anyone still looking for a partner to project 1 From 00014979@csse.uwa.edu.au Wed Aug 19 17:02:56 2015 Date: Wed Aug 19 17:02:56 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Project 1 From: "Christopher McDonald" X-smilie: none X-img: none Beginning of week 6, as indicated on our Schedule page. From abusha02@csse.uwa.edu.au Thu Aug 20 02:55:07 2015 Date: Thu Aug 20 02:55:07 2015 To: help2002@csse.uwa.edu.au Received: from 106.68.195.243 Subject: Tip for q7 and q8 in lab 3 From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none Hi everyone. Just a little tip: if you're having trouble with q7 (finding the mode), you might want to try completing q8 first. You'll have a much easier time finding the mode of a sorted array than you would an unsorted one. From jennib03@csse.uwa.edu.au Thu Aug 20 11:06:01 2015 Date: Thu Aug 20 11:06:01 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.123 Subject: Running linux inside a windows platform. From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: Virtualisation? Grab a Raspberry Pi 2! Who needs this virtualisation nonsense? :P +1 to VirtualBox if you do though, that's what I use on my mac. In theory, it should be pretty good for Windows as well? From gallj01@csse.uwa.edu.au Thu Aug 20 14:29:50 2015 Date: Thu Aug 20 14:29:50 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.128 Subject: Project 1 partner From: "James Gall" <21498933@student.uwa.edu.au> X-smilie: none X-img: none Hi - I'm looking for someone :) If you're still looking for a partner, send me an email just to confirm (21498933@student.uwa.edu.au). We can work out any other communication methods or whatever from there. From nelsoj07@csse.uwa.edu.au Thu Aug 20 15:51:23 2015 Date: Thu Aug 20 15:51:23 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.235.222 Subject: Tip for q7 and q8 in lab 3 From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Will you? Mode is the number that occurs the most, while median is the number that occurs in the center. I get why sorting would help find the median but I don't see how it helps find the mode really, how did you approach finding the mode? :) From abusha02@csse.uwa.edu.au Thu Aug 20 21:52:49 2015 Date: Thu Aug 20 21:52:49 2015 To: help2002@csse.uwa.edu.au Received: from 106.68.195.243 Subject: Tip for q7 and q8 in lab 3 From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > Will you? Mode is the number that occurs the most, while median is the number that > occurs in the center. I get why sorting would help find the median but I don't see how > it helps find the mode really, how did you approach finding the mode? :) In my experience, it seems like it'd be easier to find the mode in a sorted array, since you know you'll never encounter a number again once you pass it. If I'm dealing with a sorted array, once I pass the number 2 and hit the next number (whatever it is), I know I'll never encounter 2 again. That means that keeping track of the mode is easy, since you only need 2 counters (one for the max frequency, and one for the frequency -so far- of the number you're currently looking at). This allows you to use the intuitive method of simply checking your current frequency against your max frequency every-time you encounter a new number, and then updating max frequency (and the mode) as appropriate. If you're dealing with an unsorted array, you can't utilize such a method, since you could pass 2, and then encounter it 10 times later on; so you need to find another way to keep track of the frequency of all numbers in the array, rather than just keeping track of 2 frequencies (max and the number you're currently on). Maybe there's a better way to do it in an unsorted array than my method, but it definitely seems to me as though sorting an array would simplify the task. From graven01@csse.uwa.edu.au Fri Aug 21 15:48:57 2015 Date: Fri Aug 21 15:48:57 2015 Edit: Fri Aug 21 15:53:05 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: size of arrays in c From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none I cant seem to find an easy way of knowing how many elements are in the array. the sizeof() function seems to only return the byte size of the array so that i assume i can use something like : int size = sizeof(nums) / sizeof(nums[1]) ; but are all elements always going to be the same bit size? and is this an effective way of saving the number of elements in an array into a int variable? in java it was just nums.length why isn't there just an easy function to tell how many elements are in an array, it seems like it would be a handy thing to have. From 00014979@csse.uwa.edu.au Fri Aug 21 15:52:07 2015 Date: Fri Aug 21 15:52:07 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Tip for q7 and q8 in lab 3 From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hi everyone. Just a little tip: if you're having trouble with q7 (finding the mode), > you might want to try completing q8 first. You'll have a much easier time finding > the mode of a sorted array than you would an unsorted one. Solutions are now available; I didn't need to sort the array of values, though I do make a copy so I can overwrite its values (as does sorting). From 00014979@csse.uwa.edu.au Fri Aug 21 15:56:45 2015 Date: Fri Aug 21 15:56:45 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: size of arrays in c From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > I cant seem to find an easy way of knowing how many elements are in the array. If you allocated or requested space for the array, then you must already know how many elements it has. > but are all elements always going to be the same bit size? and is this an effective > way of saving the number of elements in an array into a int variable? The sizeof() 'trick' works *because* all array elements have the same size - if each/any array element had a different size to others, then it wouldn't be an array because the elements are not of the same datatype. > in java it was just nums.length why isn't there just an easy function to tell how many > elements are in an array, it seems like it would be a handy thing to have. As discussed in lectures - Java maintains a copy of the size; in C *you* maintain, know, or pass the size. From graven01@csse.uwa.edu.au Fri Aug 21 16:07:17 2015 Date: Fri Aug 21 16:07:17 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: size of arrays in c From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > I cant seem to find an easy way of knowing how many elements are in the array. > > If you allocated or requested space for the array, then you must already know how many elements it > has. > what if i was writing a function for somebody else's program, and they passed and variable length array to my function, sorry if i'm asking stupid questions i've had a couple. and just finished this weeks labs as i couldn't make it in this week. From 00014979@csse.uwa.edu.au Fri Aug 21 16:10:10 2015 Date: Fri Aug 21 16:10:10 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: size of arrays in c From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > what if i was writing a function for somebody else's program, and they passed and variable length array to > my function, If they pass to your function an array, then have to pass to you its length, as well. An exception to this is if they pass an array of characters representing a string. In that case, the length of the string (not of the whole array) is known because it will be terminated by a NULL-byte. > sorry if i'm asking stupid questions i've had a couple. and just finished this weeks labs as i couldn't make > it in this week. Nothing wrong with the questions! From bradfj01@csse.uwa.edu.au Sat Aug 22 10:10:28 2015 Date: Sat Aug 22 10:10:28 2015 To: help2002@csse.uwa.edu.au Received: from 1.127.49.2 Subject: Project 1 partner From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none Just wondering if anyone would like to partner up, seeing as the project will be released in week 6. Thank you. From liaoj02@csse.uwa.edu.au Sat Aug 22 22:23:45 2015 Date: Sat Aug 22 22:23:45 2015 To: help2002@csse.uwa.edu.au Received: from 43.252.114.148 Subject: What is a && (a || b) equivalent to? From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none A. true B. a C. a || !b D. !a || b Can someone explain to me? Thanks From 00014979@csse.uwa.edu.au Sun Aug 23 09:08:57 2015 Date: Sun Aug 23 09:08:57 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: What is a && (a || b) equivalent to? From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Can someone explain to me? Thanks What's your answer, and your reasoning? From liaoj02@csse.uwa.edu.au Sun Aug 23 17:55:15 2015 Date: Sun Aug 23 17:55:15 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.126.215 Subject: What is a && (a || b) equivalent to? From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none I think is A. Because C,D are not correct as a and b are both likely to happen.(a || b) thats what I am thinking. NOt sure about B though..But I think B must involve. From graven01@csse.uwa.edu.au Mon Aug 24 09:03:41 2015 Date: Mon Aug 24 09:03:41 2015 Edit: Mon Aug 24 09:04:03 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: What is a && (a || b) equivalent to? From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > I think is A. Because C,D are not correct as a and b are both likely to happen.(a || > b) thats what I am thinking. NOt sure about B though..But I think B must involve. I agree I think A as well , its not an if ( a && (a||b) , its stating a (default is a is true) and a||b (we have just stated in the first part of the statement that a is true) so the whole thing evaluates to true? but then b)a. would be also correct? because a is true? From abusha02@csse.uwa.edu.au Mon Aug 24 12:43:11 2015 Date: Mon Aug 24 12:43:11 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.156.39 Subject: What is a && (a || b) equivalent to? From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > A. true > > B. a > > C. a || !b > > D. !a || b > > Can someone explain to me? Thanks The answer to the question is (b). The expression (a && a||b) evaluates to a in the end, since it says 'if a is true, and either a or b are true, then evaluate to true'. In this case, b is actually irrelevant. a: If a is true, than a is obviously true a||b: If either a or b are true, than this is true. Thus if a is true, than a||b is true Both a and a||b must be true for (a && a||b) to be true. As such, the entire expression just evaluates to a, since if a is true, the expression is true, and if a is false, the expression is false. b has no impact on the expression. Thus the answer is (b). From abusha02@csse.uwa.edu.au Mon Aug 24 12:44:53 2015 Date: Mon Aug 24 12:44:53 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.156.39 Subject: Tip for q7 and q8 in lab 3 From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none I didn't need to either. I just found it easier with a sorted array. From 00014979@csse.uwa.edu.au Mon Aug 24 12:49:53 2015 Date: Mon Aug 24 12:49:53 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: NO CHANGE to mid-semester date or time From: "Christopher McDonald" X-smilie: none X-img: none X-announcefor: 5d There will be NO CHANGE to the date/time of the mid-semester test, so it's still as described here: http://teaching.csse.uwa.edu.au/units/CITS2002/examinations.php (sorry, too many indirect consequences if we change it). From abusha02@csse.uwa.edu.au Mon Aug 24 12:51:27 2015 Date: Mon Aug 24 12:51:27 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.156.39 Subject: What is a && (a || b) equivalent to? From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > ANONYMOUS wrote: > > > I think is A. Because C,D are not correct as a and b are both likely to happen.(a || > > b) thats what I am thinking. NOt sure about B though..But I think B must involve. > > I agree I think A as well , its not an if ( a && (a||b) , its stating a (default is a is > true) and a||b (we have just stated in the first part of the statement that a is true) so > the whole thing evaluates to true? but then b)a. would be also correct? because a is true? > Why would 'a' default to true? 'a' is just a boolean variable; if anything, most languages default booleans to false if they're not defined/initialized. But that's irrelevant. The question is just testing your understanding of logical operators. The whole expression (a && a||b) ends up evaluating to a. So the answer is: B: a Test it out and you'll see what I mean. If 'a' is true, than a && a||b must be true. Similarly, if 'a' is false, than a && a||b must be false. Thus A: True obviously can't be the correct answer. From graven01@csse.uwa.edu.au Mon Aug 24 13:09:45 2015 Date: Mon Aug 24 13:09:45 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: What is a && (a || b) equivalent to? From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none in logic: p - proposition p is true p||q - proposition p is true OR q is true (or both) since we know p is true, then the statement p||q must also be true. hence the whole expression in logic is true. i believe this is where it is confusing me. From abusha02@csse.uwa.edu.au Mon Aug 24 13:14:06 2015 Date: Mon Aug 24 13:14:06 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.156.39 Subject: What is a && (a || b) equivalent to? From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none Not quite. In logic: p - proposition p. p||q - proposition p OR proposition q i.e. p - IF p is true, this is true. OR p is false, and then this is false p||q - IF p OR q (or both) are true, then this is true p&&q - BOTH p AND q must be true for this to be true. If EITHER are false, then this is false Hence p && p||q just evaluates to p, since the expression can't be true if p is false, and can't be false if p is true. Thus the expression just has whatever truth value p has. Replace 'p' with 'a' and 'q' with 'b', and you've got your answer. From abusha02@csse.uwa.edu.au Mon Aug 24 13:17:57 2015 Date: Mon Aug 24 13:17:57 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.156.39 Subject: What is a && (a || b) equivalent to? From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none The expression: p in logic doesn't mean that p is true. It's a proposition with a truth or false value, and in this case, the proposition has whatever truth value 'p' has. If p is true, then yes, the proposition 'p' is true. But if p is false, than the proposition 'p' is false. Similarly, the proposition: p||q is again a proposition with a truth or false value, depending on the propositions p and q. It is saying, 'if either p or q are true, then this is true. If both are false, than this is false'. It is not a statement that one of them is true, it is a proposition whose truth value depends on the truth values of 'p' and 'q'. From nelsoj07@csse.uwa.edu.au Tue Aug 25 11:57:16 2015 Date: Tue Aug 25 11:57:16 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.235.222 Subject: Lab 3 Question 11 From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: angry.png X-img: none Hey guys, Completely stuck on Question 11, just can't seem to figure out the logic of it. If anyone has done it and can point me in the right direction to start or any resources explaining it better I'd be super grateful! From marshs11@csse.uwa.edu.au Tue Aug 25 13:41:05 2015 Date: Tue Aug 25 13:41:05 2015 To: help2002@csse.uwa.edu.au Received: from 168.1.6.19 Subject: Lab 3 Question 11 From: "Samuel Marsh" <21324325@student.uwa.edu.au> X-smilie: none X-img: none I'm not sure if there's a better way, but essentially I did it by continually adding one to the 'least significant' value of the state array (the most inner loop), and carrying over if necessary. This helped me: http://codereview.stackexchange.com/questions/43343/add-one-to-a-number- represented-as-an-array-of-digits From bokl01@csse.uwa.edu.au Tue Aug 25 16:43:34 2015 Date: Tue Aug 25 16:43:34 2015 Edit: Tue Aug 25 17:00:55 2015 To: help2002@csse.uwa.edu.au Received: from 134.7.91.140 Subject: q7 mid sem From: "Louis Bok" <21506299@student.uwa.edu.au> X-smilie: none X-img: none all g From newmal01@csse.uwa.edu.au Tue Aug 25 17:38:39 2015 Date: Tue Aug 25 17:38:39 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.235.56 Subject: Carriage Return From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none what does carriage return do? From newmal01@csse.uwa.edu.au Tue Aug 25 18:15:47 2015 Date: Tue Aug 25 18:15:47 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.235.56 Subject: fputs() From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none FILE *fp_in = fopen(in_filename, "r"); FILE *fp_out = fopen(out_filename, "w"); if(fp_in != NULL && fp_out != NULL) { char line[BUFSIZ]; while( fgets(line, sizeof line, fp_in) != NULL) { if(fputs(line, fp_out) == EOF) { printf("error copying file\n"); exit(EXIT_FAILURE); } } ive just got a few questions -in this example was does BUFSIZE represent, is it just the size of the declared char array? -is the fp_out varianle equal to a newly created file that does not have any characters exept for the null byte? -what exactly does the fputs function do in this case, is it simply if any line in the text is equal to "EOF" the operation creates and error and exits? From bokl01@csse.uwa.edu.au Tue Aug 25 18:30:18 2015 Date: Tue Aug 25 18:30:18 2015 To: help2002@csse.uwa.edu.au Received: from 134.7.91.140 Subject: fork() From: "Louis Bok" <21506299@student.uwa.edu.au> X-smilie: none X-img: none Does anyone know the answer to question 20 of mid sem? I believe it's c. because the fork() function duplicates twice resulting in 4 processes. But I'm uneasy with the overall syntax. Thank you!! From bokl01@csse.uwa.edu.au Tue Aug 25 18:34:06 2015 Date: Tue Aug 25 18:34:06 2015 To: help2002@csse.uwa.edu.au Received: from 134.7.91.140 Subject: Carriage Return From: "Louis Bok" <21506299@student.uwa.edu.au> X-smilie: none X-img: none It is a control mechanism that moves your position back to the beginning of the current line you're on.Denoted by \r. From fetzee01@csse.uwa.edu.au Tue Aug 25 18:40:55 2015 Date: Tue Aug 25 18:40:55 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: fork() From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none fork call is in the lectures after the test, does this mean we can expect it to not be in the test? From motts02@csse.uwa.edu.au Tue Aug 25 20:21:24 2015 Date: Tue Aug 25 20:21:24 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.63.85 Subject: Project 1 partner From: "Stephen Mott" <21140413@student.uwa.edu.au> X-smilie: none X-img: none I'm looking for a project partner for project 1 too Send me an email at 21140413@student.uwa.edu.au I'm free most of mon, thurs, fri From bradfj01@csse.uwa.edu.au Tue Aug 25 20:40:27 2015 Date: Tue Aug 25 20:40:27 2015 To: help2002@csse.uwa.edu.au Received: from 60.224.9.24 Subject: Project 1 partner From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none Awesome, I've just sent you an email :) From itlioj01@csse.uwa.edu.au Tue Aug 25 20:50:50 2015 Date: Tue Aug 25 20:50:50 2015 To: help2002@csse.uwa.edu.au Received: from 144.131.243.40 Subject: Project 1 partner From: "James Itliong" <21487513@student.uwa.edu.au> X-smilie: none X-img: none Hi! I'm also looking for a partner for Project 1. My email is 21487513@student.uwa.edu.au if anyone is interested. Thanks :) From abusha02@csse.uwa.edu.au Wed Aug 26 01:30:49 2015 Date: Wed Aug 26 01:30:49 2015 To: help2002@csse.uwa.edu.au Received: from 106.68.195.243 Subject: fork() From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > Does anyone know the answer to question 20 of mid sem? > I believe it's c. because the fork() function duplicates > twice resulting in 4 processes. But I'm uneasy with the overall > syntax. > Thank you!! I don't have the question in front of me at the moment, but if I recall it was something like fork(); fork(); printf("hello world\n"); In this case, "hello world" will be printed 4 times, on 4 separate lines. From 00014979@csse.uwa.edu.au Wed Aug 26 04:23:00 2015 Date: Wed Aug 26 04:23:00 2015 Edit: Wed Aug 26 04:23:16 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: fputs() From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: (I'm wondering if you're asking these questions without attending the lecture (and asking questions, then), or having watched the lecture?) > -in this example was does BUFSIZE represent, is it just the size of the declared char > array? (as discussed in the lecture) it's intended to be a size that will facilitate efficient block-based transfers between an application program and (likely) a disk. > -is the fp_out varianle equal to a newly created file that does not have any > characters exept for the null byte? fp_out is *not* a file; it refers (in this example) to a newly opened file (which may be new or already exist), and fp_out is used to perform future operations on/to that file. Read the online manual - man fopen > -what exactly does the fputs function do in this case, is it simply if any line in the > text is equal to "EOF" the operation creates and error and exits? Read the online manual - man fputs and try the example code for yourself. From 00014979@csse.uwa.edu.au Wed Aug 26 04:25:28 2015 Date: Wed Aug 26 04:25:28 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: fork() From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > fork call is in the lectures after the test, does this mean we can expect it to not > be in the test? Yes, we will talk more about fork() and process creation after the test, but we have 'discussed' its role, in lectures, sufficiently to answer this and similar questions. From itlioj01@csse.uwa.edu.au Wed Aug 26 14:02:56 2015 Date: Wed Aug 26 14:02:56 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.127.209 Subject: Project 1 partner From: "James Itliong" <21487513@student.uwa.edu.au> X-smilie: none X-img: none Update: someone has already emailed me. From vijp01@csse.uwa.edu.au Wed Aug 26 14:51:33 2015 Date: Wed Aug 26 14:51:33 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.138.74 Subject: Lab 3 Question 11 From: "Pradyumn Vij" <21469477@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > Hey guys, > > Completely stuck on Question 11, just can't seem to figure out the logic of it. If > anyone has done it and can point me in the right direction to start or any resources > explaining it better I'd be super grateful! This is super easy to do, just put your loop in a function that recursively calls itself. Define the number of recurrences of the loop by passing a number along as an argument and reducing that number for every recursive call (or whenever you need to based on what you want your "super loop" to do). From lopasb03@csse.uwa.edu.au Wed Aug 26 15:39:43 2015 Date: Wed Aug 26 15:39:43 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.100.167 Subject: Project 1 partner From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: thumbup.png X-img: none "James Itliong" <21487513@student.uwa.edu.au> wrote: > Update: someone has already emailed me. Hi, I am also looking for a partner for project 1, my email is: 19922921@student.uwa.edu.au Thanks, Ben. c",) From led05@csse.uwa.edu.au Wed Aug 26 15:50:58 2015 Date: Wed Aug 26 15:50:58 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.154.139 Subject: What is a && (a || b) equivalent to? From: "Henry Le" <21317911@student.uwa.edu.au> X-smilie: none X-img: none Use boolean algebra: a&&(a||b) = A(A+B) =AA + AB =A + AB =A(1+B) =A(1) =A the ans is B. a From mcfald01@csse.uwa.edu.au Wed Aug 26 23:15:36 2015 Date: Wed Aug 26 23:15:36 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.167.103 Subject: Project 1 partner From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none I'm also looking for a project partner if anybody would like, my email is 21312007@student.uwa.edu.au Thanks, Daniel From 00014979@csse.uwa.edu.au Thu Aug 27 04:53:18 2015 Date: Thu Aug 27 04:53:18 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Mid-semester test - Tutorial on Friday 28th From: "Christopher McDonald" X-smilie: none X-img: none X-announcefor: 36h Our tutorial on Friday 28th will focus on questions from the 2014 mid-semester test. We'll not just go through every question, as many answers are clear, but focus on the quesstions that YOU'RE interested in. So, before 6AM Friday, please email me the question numbers you'd like discussed (and why). Thanks, From abusha02@csse.uwa.edu.au Thu Aug 27 08:23:04 2015 Date: Thu Aug 27 08:23:04 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.156.39 Subject: What is a && (a || b) equivalent to? From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none "Henry Le" <21317911@student.uwa.edu.au> wrote: > Use boolean algebra: > a&&(a||b) = A(A+B) > =AA + AB > =A + AB > =A(1+B) > =A(1) > =A > the ans is B. a You really don't need to do that much work to solve the question. If you understand basic propositional logic, the answer should almost be self-evident. Not everyone taking this unit is going to know how to use boolean algebra either. From bradfj01@csse.uwa.edu.au Thu Aug 27 10:47:30 2015 Date: Thu Aug 27 10:47:30 2015 To: help2002@csse.uwa.edu.au Received: from 49.196.11.125 Subject: Lab04 - Q2 From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none Just wondering how you would store the card symbols and numbers. I tried a two dimensional array, but got slightly confused. From 00014979@csse.uwa.edu.au Thu Aug 27 10:52:15 2015 Date: Thu Aug 27 10:52:15 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Lab04 - Q2 From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Just wondering how you would store the card symbols and numbers. I tried a two > dimensional array, but got slightly confused. Do you really need to *store* them anywhere, or just to print out the "names" of cards after they've been shuffled? From bradfj01@csse.uwa.edu.au Thu Aug 27 10:55:51 2015 Date: Thu Aug 27 10:55:51 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.71.120 Subject: Lab04 - Q2 From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > Just wondering how you would store the card symbols and numbers. I tried a two > > dimensional array, but got slightly confused. > > Do you really need to *store* them anywhere, or just to print out the "names" of cards > after they've been shuffled? Thank you Chris, that helps a bit more. From nelsoj07@csse.uwa.edu.au Thu Aug 27 13:32:16 2015 Date: Thu Aug 27 13:32:16 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.235.222 Subject: Lab 3 Question 11 From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Am I missing something or does that not perform nested loops though? It seems like that will make it perform n loops, but not nested. So if n = 3, then that recursive function you describe would run 3 loops, not 3^3? From nelsoj07@csse.uwa.edu.au Thu Aug 27 13:42:15 2015 Date: Thu Aug 27 13:42:15 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.235.222 Subject: fork() From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Try running the code given! #include #include #include void function(void) { fork(); fork(); printf("Hello world\n"); } int main(int argc, char *argv[]) { function(); exit(EXIT_SUCCESS); } Should help clarify it! From johnsd16@csse.uwa.edu.au Thu Aug 27 14:06:29 2015 Date: Thu Aug 27 14:06:29 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.231.201 Subject: Lab work critique From: "Dylan Johnson" <21469038@student.uwa.edu.au> X-smilie: none X-img: none Hi, could I get one of the teachers to do a critique of my solutions to some of the labsheets (things like formatting, efficiency, etc)? I'll link the source files from my DropBox account. Labsheet 3 min/max/avg calculator: https://www.dropbox.com/s/6rg67vkunnuzcif/MinMaxAvg.c?dl=0 Labsheet 3 word analyser: https://www.dropbox.com/s/wt6p1rlsec643pt/StringAnalyze.c?dl=0 Labsheet 4 card shuffler: https://www.dropbox.com/s/jz1jgljwgjqly1x/CardShuffle.c?dl=0 From vijp01@csse.uwa.edu.au Thu Aug 27 19:26:39 2015 Date: Thu Aug 27 19:26:39 2015 To: help2002@csse.uwa.edu.au Received: from 220.253.189.122 Subject: Lab 3 Question 11 From: "Pradyumn Vij" <21469477@student.uwa.edu.au> X-smilie: thumbup.png X-img: none So your internal loop will do whatever bounds you want, in your example 3. This can be hard coded or part of your superloop function or it can even vary for each loop if you need it to. Below is a simplistic solution to the problem. #include #include void superloop(int numberOfLoops, int bounds){ if(numberOfLoops > 0){ // Put in whatever loop you want, while or for. for(int i = 0; i < bounds; ++i){ // Do something with your loop printf("Number %i of nest number %i\n", i, numberOfLoops); } superloop(--numberOfLoops, bounds); } } int main(int argc, char *argv[]){ if(argc != 3){ fprintf(stderr, "%s Usage: Single number argument is required \ First argument = number of full loops \ Second argument = loop bounds", argv[0]); exit(EXIT_FAILURE); } superloop(atoi(argv[1]), atoi(argv[2])); exit(EXIT_SUCCESS); return 0; } From 00014979@csse.uwa.edu.au Thu Aug 27 19:39:16 2015 Date: Thu Aug 27 19:39:16 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Lab work critique From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hi, could I get one of the teachers to do a critique of my solutions to some of the > labsheets (things like formatting, efficiency, etc)? I'll link the source files from > my DropBox account. No-one else, I guess. Your formatting looks fine in all 3 examples - the primary objective is to be consistent, rather than strictly following a single format. In your second solution, in your stringLength() function, you don't need both variables i and count. Just one. Many times, you use for(int i=0; i < stringLength(string); i++) As discussed in lectures, DO NOT call a function to repeatedly calculate the length of a string (unless that string ever changes). In a few places you use if('0' <= string[i] && string[i] <= '9') You can avoid these tests by calling standard functions such as isdigit(), isupper(), isalpha(), ... There's a simpler solution to the card shuffling problem which doesn't require the more complicated management of 2-dim arrays. You only really need the suits and ranks when you're about to print each card. From ahmedm07@csse.uwa.edu.au Thu Aug 27 20:53:21 2015 Date: Thu Aug 27 20:53:21 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.71.141 Subject: Mid-Semester Test - Ratio of Operating System and C language questions From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none Hey, Just a small question to anyone who might know of the answer. The mid semester example exam does not really have a lot of operating system related questions. I am wondering if that is same sort of ratio we will have in the upcoming test. Also, will it be the same sort of questions. Like having 20 multiple choice questions. Let me know if i am asking the wrong questions or whatever, Thanks. MA From 00014979@csse.uwa.edu.au Fri Aug 28 04:32:03 2015 Date: Fri Aug 28 04:32:03 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Mid-Semester Test - Ratio of Operating System and C language questions From: "Christopher McDonald" X-smilie: none X-img: none "Maktoom Ahmed" <21728592@student.uwa.edu.au> wrote: > Hey, > > Just a small question to anyone who might know of the answer. The mid semester > example exam does not really have a lot of operating system related questions. I am > wondering if that is same sort of ratio we will have in the upcoming test. Also, will > it be the same sort of questions. Like having 20 multiple choice questions. From last year's test, Q14,15,17-20 can all be considered OS questions, or ones that discuss the interface between a programming language and the OS. That 6/20 questions is about the same ratio as that of lectures: 3-4 lectures of our 10. But don't bank on an exact ratio - maybe Tuesday's test will have 1 or 2 more, or less, questions of any type. re: "Like having 20 multiple choice questions" - it's unclear how you could have missed this webpage: http://teaching.csse.uwa.edu.au/units/CITS2002/examinations.php From zhangj47@csse.uwa.edu.au Fri Aug 28 11:45:06 2015 Date: Fri Aug 28 11:45:06 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.72.53 Subject: What is a && (a || b) equivalent to? From: "Jin ZHANG" <21687443@student.uwa.edu.au> X-smilie: none X-img: none i think u don't need to think so much about the logic, instead, just put some practical numbers in it. For example, a=0,b=1 and a=0,b=0 , by this way ,we can pass c and d, and try more i think the most possible answer is B.a From ahmedm07@csse.uwa.edu.au Fri Aug 28 13:02:38 2015 Date: Fri Aug 28 13:02:38 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.71.141 Subject: Mid-Semester Test - Ratio of Operating System and C language questions From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > "Maktoom Ahmed" <21728592@student.uwa.edu.au> wrote: > > > Hey, > > > > Just a small question to anyone who might know of the answer. The mid semester > > example exam does not really have a lot of operating system related questions. I am > > wondering if that is same sort of ratio we will have in the upcoming test. Also, will > > it be the same sort of questions. Like having 20 multiple choice questions. > > From last year's test, Q14,15,17-20 can all be considered OS questions, or ones that discuss the > interface between a programming language and the OS. That 6/20 questions is about the same ratio > as that of lectures: 3-4 lectures of our 10. > But don't bank on an exact ratio - maybe Tuesday's test will have 1 or 2 more, or less, questions > of any type. > > re: "Like having 20 multiple choice questions" - it's unclear how you could have missed this > webpage: > http://teaching.csse.uwa.edu.au/units/CITS2002/examinations.php Ok. Thanks for clearing that up. Re: "it's unclear how you could have missed this webpage" - That is a fair point. I also do not see how i did not see that. Thanks anyhow. :) From johnsd16@csse.uwa.edu.au Fri Aug 28 13:59:33 2015 Date: Fri Aug 28 13:59:33 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.231.201 Subject: Lab work critique From: "Dylan Johnson" <21469038@student.uwa.edu.au> X-smilie: none X-img: none I re-did the CardShuffle, how's this? https://www.dropbox.com/s/iqnov0e6apxc692/CardShuffleV2.c?dl=0 From 00014979@csse.uwa.edu.au Fri Aug 28 15:44:03 2015 Date: Fri Aug 28 15:44:03 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Lab work critique From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > I re-did the CardShuffle, how's this? Yes, that looks better (because it looks simpler). Only minor, but you only really need one extra variable to swap two others when shuffling, and you shouldn't really need a loop of 100 to shuffle the deck, just a loop of 51 :-) From lopasb03@csse.uwa.edu.au Fri Aug 28 16:04:43 2015 Date: Fri Aug 28 16:04:43 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.100.167 Subject: Mid Semester Questions and Solutions From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Hi, Can we get the solutions to the 2014 mid-semester test? Also, are there any other questions or tests that we can practice and get the solutions to, in order to prepare for next weeks test? Thanks. ;) From chinnd01@csse.uwa.edu.au Fri Aug 28 16:21:30 2015 Date: Fri Aug 28 16:21:30 2015 To: help2002@csse.uwa.edu.au Received: from 1.127.48.19 Subject: Mid Semester Questions and Solutions From: "David Chinnery" <21142701@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > Hi, > > Can we get the solutions to the 2014 mid-semester test? Also, are there any other > questions or tests that we can practice and get the solutions to, in order to > prepare for next weeks test? > > Thanks. ;) The solutions to the 2014 test are already up. In the mid semester test section. Dave From penmaa01@csse.uwa.edu.au Fri Aug 28 16:39:45 2015 Date: Fri Aug 28 16:39:45 2015 To: help2002@csse.uwa.edu.au Received: from 60.224.228.59 Subject: Lab 3 Question 11 From: "Alasdair Penman" <21127109@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > Hey guys, > > Completely stuck on Question 11, just can't seem to figure out the logic of it. If > anyone has done it and can point me in the right direction to start or any resources > explaining it better I'd be super grateful! . From penmaa01@csse.uwa.edu.au Fri Aug 28 17:06:19 2015 Date: Fri Aug 28 17:06:19 2015 Edit: Fri Aug 28 17:09:46 2015 To: help2002@csse.uwa.edu.au Received: from 60.224.228.59 Subject: Lab 3 Question 11 From: "Alasdair Penman" <21127109@student.uwa.edu.au> X-smilie: none X-img: 854d19a8a3fc948b2e12e1c7a905d86b.c "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > Hey guys, > > Completely stuck on Question 11, just can't seem to figure out the logic of it. If > anyone has done it and can point me in the right direction to start or any resources > explaining it better I'd be super grateful! You can also do it without recursion, which is relatively slow. I used a goto statement and a one dimensional array to keep track of the state of our nested loop. The code is 95% complete and you can check it works in principle by printing out the array state where do you work. I have attached the code. It works by treating the nested loop like a binary tree. It should be faster than recursion. #include #include int main(int argc, char *argv[] ) { //Number of loops //int N = atoi(argv[1]); //How wide you want your loop //int I = atoi(argv[2]); //To demonstrate use N = 4, I = 4. Four nested loops, and I-1 = 3 "wide": // for(int i = 0; i < I-1; i++) int N = 4, I = 4; int loop[N]; int errorMsg = 0; int count = 0; int a = 0; for (int i = 0; i < N; i++ ) loop[ i ] = 0; // "nested", where we want to jump back to using goto nested: //The main loop for (int i = a; i < I; i++) { if( count != N-1) { loop[ count ]++; count++; goto nested; } loop[ count ]++; } printf("\n"); //Do work here. Print out state of nested loop using array for(int i = 0; i < N-1; i++) printf("%i ", loop[ i ]); //Loop control. Determine loop state, and whether to go back to main loop. //Needs fine tuning but demonstrates concept works. for(int i = 0; i < N; i++) { if(loop[ 0 ] == I) break; if(loop[ i ] == I) { loop[ i ] = 0; count = i - 1; for(int j = i; j < N; j++) loop[ j ] = 0; //for(int i = 0; i < N; i++) printf("%i ", loop[ i ]); goto nested; } } printf("\n"); } From penmaa01@csse.uwa.edu.au Fri Aug 28 18:36:22 2015 Date: Fri Aug 28 18:36:22 2015 To: help2002@csse.uwa.edu.au Received: from 60.224.228.59 Subject: Lab 3 Question 11 From: "Alasdair Penman" <21127109@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > Hey guys, > > Completely stuck on Question 11, just can't seem to figure out the logic of it. If > anyone has done it and can point me in the right direction to start or any resources > explaining it better I'd be super grateful! I made an error. The work should be done in the "main loop". I have cleaned up the code: #include #include int main(int argc, char *argv[] ) { //Enter N for the number of loops //int N = atoi(argv[1]); //Enter I for the width of the loop //int I = atoi(argv[2]); //To demonstrate use N = 4, I = 4. Four nested loops, and I = 4 "wide": // for(int i = 0; i < I; i++) int N = 4, I = 4; int loop[N]; int count = 0; for (int i = 0; i < N; i++ ) loop[ i ] = 0; // "nested", where we want to jump back to using goto nested: //The main loop. All work done in main loop. for (int i = 0; i < I; i++) { //Loop control. Ensure loop is in correct state. if( count != N-1) { loop[ count ]++; count++; goto nested; } loop[ count ]++; //Do work here. Print state of loop, to show program is working. for(int i = 0; i < N; i++) printf("%i ", loop[ i ]); printf("\n"); } //Loop control. Determine loop state, and whether to go back to main loop. //Needs fine tuning but demonstrates concept works. for(int i = 0; i < N; i++) { if(loop[ 0 ] == I) break; if(loop[ i ] == I) { loop[ i ] = 0; count = i - 1; for(int j = i; j < N; j++) loop[ j ] = 0; goto nested; } } } From 00014979@csse.uwa.edu.au Fri Aug 28 19:44:26 2015 Date: Fri Aug 28 19:44:26 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Lab 3 Question 11 From: "Christopher McDonald" X-smilie: none X-img: none "Alasdair Penman" <21127109@student.uwa.edu.au> wrote: > You can also do it without recursion, which is relatively slow. I used a goto statement and a > one dimensional array to keep track of the state of our nested loop. The code is 95% complete > and you can check it works in principle by printing out the array state where do you work. I > have attached the code. There's a well established belief in Computer Science that use of the 'goto' statement is a bad thing; it's been proved that a goto is never necessary, and most newer programming languages don't even provide it. The belief commenced way back in 1968, when the now extremely famous computer scientist Edgar Dijkstra published a communication "Go To Statement Considered Harmful": http://homepages.cwi.nl/~storm/teaching/reader/Dijkstra68.pdf In the code you've provided the goto is not necessary - you can replace it with another while loop around the statements involving the 'goto nested', and replacing 'goto needed;' with 'i = N;' From 00014979@csse.uwa.edu.au Fri Aug 28 19:45:19 2015 Date: Fri Aug 28 19:45:19 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Mid Semester Questions and Solutions From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hi, > > Can we get the solutions to the 2014 mid-semester test? Also, are there any other > questions or tests that we can practice and get the solutions to, in order to > prepare for next weeks test? Good textbooks, on either C or OS, usually have questions in end-of-chapter exercises. From vijp01@csse.uwa.edu.au Sat Aug 29 12:13:01 2015 Date: Sat Aug 29 12:13:01 2015 To: help2002@csse.uwa.edu.au Received: from 220.253.189.122 Subject: Lab 3 Question 11 From: "Pradyumn Vij" <21469477@student.uwa.edu.au> X-smilie: none X-img: none Note that making the generalisation that recursion is slower than iteration is incorrect, it can vary from language to language and what the function is doing. The downside of recursion is memory however if the hardware running the software can reasonably deal with the recursive task. However recursion is often easier to read. From heinsm01@csse.uwa.edu.au Sat Aug 29 12:30:45 2015 Date: Sat Aug 29 12:30:45 2015 To: help2002@csse.uwa.edu.au Received: from 126.221.7.17 Subject: Lab 3 Question 11 From: "Matthew Heinsen Egan" <10430227@student.uwa.edu.au> X-smilie: none X-img: none "Pradyumn Vij" <21469477@student.uwa.edu.au> wrote: > Note that making the generalisation that recursion is slower than iteration is incorrect, it can vary > from language to language and what the function is doing. > The downside of recursion is memory however if the hardware running the software can reasonably deal > with the recursive task. > However recursion is often easier to read. Memory may not be a downside, if the recursive function is amenable to tail call elimination and the language/compiler supports it :) From warnel02@csse.uwa.edu.au Sat Aug 29 14:37:19 2015 Date: Sat Aug 29 14:37:19 2015 To: help2002@csse.uwa.edu.au Received: from 114.30.118.67 Subject: Project 1 partner From: "Luke Warner" <20930781@student.uwa.edu.au> X-smilie: none X-img: none Hi, Also looking for someone to partner up with! Hit me up at: 20930781@student.uwa.edu.au Luke. From lopasb03@csse.uwa.edu.au Sat Aug 29 16:31:27 2015 Date: Sat Aug 29 16:31:27 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.88.132 Subject: fork() From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: nerd.png X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > Try running the code given! > > #include > #include > #include > > void function(void) > { > fork(); > fork(); > printf("Hello world\n"); > } > > int main(int argc, char *argv[]) > { > function(); > exit(EXIT_SUCCESS); > } > > Should help clarify it! Hi, I compiled my code using the following syntax: void function(void) { fork(); fork(); printf("hello world\n"); } int main(void) { function(); return 0; } And, as expected it prints "hello world" 4 times on seperate lines; However, the solutions to the mid-semester test state that 'D' is the right answer. Which says "The form of the output cannot be determined from the above code", is this because a different operating system may give a different result, or is this a typo in the solutions? From bradfj01@csse.uwa.edu.au Sat Aug 29 17:38:48 2015 Date: Sat Aug 29 17:38:48 2015 To: help2002@csse.uwa.edu.au Received: from 49.196.10.15 Subject: fork() From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none I thought that C language is Operating System independent, meaning that it can be compiled on most systems. I don't know, please let me know if I'm going wrong. I read it in the book that is prescribed on this website. From chinnd01@csse.uwa.edu.au Sat Aug 29 19:56:20 2015 Date: Sat Aug 29 19:56:20 2015 To: help2002@csse.uwa.edu.au Received: from 60.228.208.15 Subject: fork() From: "David Chinnery" <21142701@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > I thought that C language is Operating System independent, meaning that it can be > compiled on most systems. I don't know, please let me know if I'm going wrong. I read it > in the book that is prescribed on this website. Yeah not always as the Microsoft MSDN states. "One of the largest areas of difference is in the process model. UNIX has fork; Win32 does not" Got me too even after I wrote a test program it failed to compile on a windows machine ( but it worked on Linux). I said C. ( 4x hello) I guess the lesson here is to read the actual question. If it said "What would the output be under Linux" then it would be a different story. https://msdn.microsoft.com/en-us/library/y23kc048.aspx From 00014979@csse.uwa.edu.au Sun Aug 30 07:25:30 2015 Date: Sun Aug 30 07:25:30 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Lab 3 Question 11 From: "Christopher McDonald" X-smilie: none X-img: none "Pradyumn Vij" <21469477@student.uwa.edu.au> wrote: > Below is a simplistic solution to the problem. > > > void superloop(int numberOfLoops, int bounds){ > if(numberOfLoops > 0){ > // Put in whatever loop you want, while or for. > for(int i = 0; i < bounds; ++i){ > // Do something with your loop > printf("Number %i of nest number %i\n", i, numberOfLoops); > } > superloop(--numberOfLoops, bounds); > } > } Like Jake, I'm not convinced that the above provides a solution. If we're running 3 nested loops, each from 1..10, then the code should print 1000 lines, whereas yours will only print 30 (or is your code not your whole solution?) I've added a couple of solutions, that don't employ recursion, to the sample solutions page. From liaoj02@csse.uwa.edu.au Sun Aug 30 12:39:48 2015 Date: Sun Aug 30 12:39:48 2015 Edit: Sun Aug 30 12:42:30 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.124.246 Subject: Few quiries about the mid test solution From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Hi, I have a few questions that still don't understand at the moment.Hope someone can give me an idea. Thanks 9.Consider a function of type void. Which of the following statements about the number of return statements contained within the function is true? A. The function must have precisely 0 return statements. B. The function must have precisely 1 return statement. C. The function must have at least 1 return statement. D. The function may have any number of (including 0) return statements. The answer is D, but isn't void doesn't have a return statement? (11) Which of the following statements about character arrays in C is/are true? i. Indexing starts from 1. ii. Character arrays are always terminated by the NULL-byte. iii. Array elements are all of the same data type. For Statement ii , is it true that if the character array is initialized by typing a string quoted rather than supplying single letter one by one then it will not end with null byte? If not, why it is wrong? (12) Which of the following array initialization statements is valid? i. char array[] = "hello"; ii. char array[5] = "hello"; iii. char array[6] = "hello"; A. iii only. B. i. and ii. only. C. i. and iii. only D. All of i., ii., and iii. Does Statement ii incur buffer overflow? Thanks From vijp01@csse.uwa.edu.au Sun Aug 30 16:01:17 2015 Date: Sun Aug 30 16:01:17 2015 To: help2002@csse.uwa.edu.au Received: from 220.253.189.122 Subject: Lab 3 Question 11 From: "Pradyumn Vij" <21469477@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > > Like Jake, I'm not convinced that the above provides a solution. > If we're running 3 nested loops, each from 1..10, then the code should print 1000 lines, > whereas yours will only print 30 (or is your code not your whole solution?) > > I've added a couple of solutions, that don't employ recursion, to the sample solutions page. I have probably misinterpreted the question but the above should be easily altered to achieve an appropriate result. I haven't tested it I just thought of recursion as another possible way to re-purpose an initial loop. From 00014979@csse.uwa.edu.au Sun Aug 30 17:26:56 2015 Date: Sun Aug 30 17:26:56 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Few quiries about the mid test solution From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hi, I have a few questions that still don't understand at the moment.Hope someone can > give me an idea. Thanks > > 9.Consider a function of type void. Which of the following statements about the > number > of return statements contained within the function is true? > A. The function must have precisely 0 return statements. > B. The function must have precisely 1 return statement. > C. The function must have at least 1 return statement. > D. The function may have any number of (including 0) return statements. > > The answer is D, but isn't void doesn't have a return statement? The function can have return statements (indicating that control should go back to the function that called this one), but the return statement(s) don't provide any particular value/data to return. > (11) Which of the following statements about character arrays in C is/are true? > i. Indexing starts from 1. > ii. Character arrays are always terminated by the NULL-byte. > iii. Array elements are all of the same data type. > > For Statement ii , is it true that if the character array is initialized by typing a > string quoted rather than supplying single letter one by one then it will not end > with null byte? If not, why it is wrong? Arrays of characters can be used for things other than strings (e.g. just holding a vector of characters/small integers). Such an array does not have to have a NULL-byte (anywhere, or at its end). > (12) Which of the following array initialization statements is valid? > i. char array[] = "hello"; > ii. char array[5] = "hello"; > iii. char array[6] = "hello"; > A. iii only. > B. i. and ii. only. > C. i. and iii. only > D. All of i., ii., and iii. > > Does Statement ii incur buffer overflow? No, because the array has been defined to have exactly 5 characters, unlike i. where the array allocates 6 bytes, including the one for the NULL-byte. From 00014979@csse.uwa.edu.au Sun Aug 30 17:31:18 2015 Date: Sun Aug 30 17:31:18 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: fork() From: "Christopher McDonald" X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > And, as expected it prints "hello world" 4 times on seperate lines; However, > the solutions to the mid-semester test state that 'D' is the right answer. Which > says "The form of the output cannot be determined from the above code", is this > because a different operating system may give a different result, or is this > a typo in the solutions? What actually happens depends on the interleaving/scheduling of the 4 running processes, whether they buffer their output (and maybe some external factors, but that would be too pedantic to ask about). In short, from the short bit of code, we can't tell what may happen. From 00014979@csse.uwa.edu.au Sun Aug 30 17:36:01 2015 Date: Sun Aug 30 17:36:01 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: fork() From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > I thought that C language is Operating System independent, meaning that it can be > compiled on most systems. I don't know, please let me know if I'm going wrong. I read it > in the book that is prescribed on this website. Yes, C is OS independent, meaning that the language makes no strong demands of the OS on which its programs run. But that's not related to the question - fork() is not a function defined as part of the standard C library, it's a system-call (function) provided by some OSs. Similarly, a C program, compiled and running on Windows, may be able to call a function named Start_Microsoft_Office(), but that's unrelated to whether or not C is OS independent. From 00014979@csse.uwa.edu.au Sun Aug 30 17:38:55 2015 Date: Sun Aug 30 17:38:55 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: fork() From: "Christopher McDonald" X-smilie: none X-img: none "David Chinnery" <21142701@student.uwa.edu.au> wrote: > Got me too even after I wrote a test program it failed to compile on a windows machine ( but it > worked on Linux). I said C. ( 4x hello) I guess the lesson here is to read the actual question. > If it said "What would the output be under Linux" then it would be a different story. No, don't try and read too much into the question - it's not trying to be tricky. The question asks "If the above code executes successfully....", so the code must have already compiled and linked successfully to get that far. From johnsd16@csse.uwa.edu.au Mon Aug 31 11:07:51 2015 Date: Mon Aug 31 11:07:51 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.231.201 Subject: Project 1 partner From: "Dylan Johnson" <21469038@student.uwa.edu.au> X-smilie: none X-img: none Hey all, I need a a partner too if anyone is still looking. From newmal01@csse.uwa.edu.au Mon Aug 31 12:28:46 2015 Date: Mon Aug 31 12:28:46 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.149.225 Subject: Project 1 From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none Hey just wondering when project 1 will be availabe From 00014979@csse.uwa.edu.au Mon Aug 31 12:47:57 2015 Date: Mon Aug 31 12:47:57 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Project 1 From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hey just wondering when project 1 will be availabe Tomorrow; From penmaa01@csse.uwa.edu.au Mon Aug 31 13:57:25 2015 Date: Mon Aug 31 13:57:25 2015 To: help2002@csse.uwa.edu.au Received: from 60.224.228.59 Subject: Lab 3 Question 11 From: "Alasdair Penman" <21127109@student.uwa.edu.au> X-smilie: none X-img: none Thanks From liaoj02@csse.uwa.edu.au Mon Aug 31 15:17:29 2015 Date: Mon Aug 31 15:17:29 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.103.179 Subject: Few quiries about the mid test solution From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > Hi, I have a few questions that still don't understand at the moment.Hope someone can > > give me an idea. Thanks > > > > 9.Consider a function of type void. Which of the following statements about the > > number > > of return statements contained within the function is true? > > A. The function must have precisely 0 return statements. > > B. The function must have precisely 1 return statement. > > C. The function must have at least 1 return statement. > > D. The function may have any number of (including 0) return statements. > > > > The answer is D, but isn't void doesn't have a return statement? > > The function can have return statements (indicating that control should go back to the function > that called this one), but the return statement(s) don't provide any particular value/data to > return. > > > > (11) Which of the following statements about character arrays in C is/are true? > > i. Indexing starts from 1. > > ii. Character arrays are always terminated by the NULL-byte. > > iii. Array elements are all of the same data type. > > > > For Statement ii , is it true that if the character array is initialized by typing a > > string quoted rather than supplying single letter one by one then it will not end > > with null byte? If not, why it is wrong? > > Arrays of characters can be used for things other than strings (e.g. just holding a vector of > characters/small integers). > Such an array does not have to have a NULL-byte (anywhere, or at its end). > > > > > (12) Which of the following array initialization statements is valid? > > i. char array[] = "hello"; > > ii. char array[5] = "hello"; > > iii. char array[6] = "hello"; > > A. iii only. > > B. i. and ii. only. > > C. i. and iii. only > > D. All of i., ii., and iii. > > > > Does Statement ii incur buffer overflow? > > No, because the array has been defined to have exactly 5 characters, unlike i. where the array > allocates 6 bytes, including the one for the NULL-byte. Thank you. When I performed the strlen for each of the 3 array with "hello", the second one has length of 10, is it because of buffer? From 00014979@csse.uwa.edu.au Mon Aug 31 15:32:08 2015 Date: Mon Aug 31 15:32:08 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Few quiries about the mid test solution From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > When I performed the strlen for each of the 3 array with "hello", the second one has length of 10, > is it because of buffer? When I compile and run: char array1[5] = "hello"; int main(int argc, char *argv[]) { char array2[5] = "hello"; printf("%i %i\n", (int)strlen(array1), (int)strlen(array2)); return 0; } the output is '5 11' on my OS-X desktop, and '5 33' on my Linux box. It just all depends on where the next NULL-byte is. Which 'buffer' do you mean? From nelsoj07@csse.uwa.edu.au Mon Aug 31 15:44:15 2015 Date: Mon Aug 31 15:44:15 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.235.222 Subject: Lab 3 Question 11 From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: sorcerer.png X-img: none Thanks Chris, those solutions are great! From jennib03@csse.uwa.edu.au Mon Aug 31 19:19:09 2015 Date: Mon Aug 31 19:19:09 2015 Edit: Mon Aug 31 19:24:05 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.64.229 Subject: Project 1 partner From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none > Hey all, I need a a partner too if anyone is still looking. Anyone still looking for a partner? I need a partner as well. From graven01@csse.uwa.edu.au Mon Aug 31 19:52:20 2015 Date: Mon Aug 31 19:52:20 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Project 1 partner From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none If anyone would like a electronic correspondence (skye, email, sms etc) partner only shoot me an email,21256779@student.uwa.edu.au , very rarely attend the campus as i live over an hour away. From bahrj01@csse.uwa.edu.au Mon Aug 31 20:20:21 2015 Date: Mon Aug 31 20:20:21 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.151.6 Subject: Project 1 partner From: "Julian Bahr" <19026320@student.uwa.edu.au> X-smilie: none X-img: none "Benjamin Jennings" <21460003@student.uwa.edu.au> wrote: > > Hey all, I need a a partner too if anyone is still looking. > > Anyone still looking for a partner? I need a partner as well. If your still looking sign me up From graven01@csse.uwa.edu.au Mon Aug 31 21:46:54 2015 Date: Mon Aug 31 21:46:54 2015 Edit: Mon Aug 31 22:10:18 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: q7 2014 MST From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none why does 1/2 round down? ( i'm assuming it will always round down) is it the norm in most languages and is there a good reason for it, besides convention? edit it seems evem 9/10 rounds down... From 00014979@csse.uwa.edu.au Tue Sep 1 04:19:43 2015 Date: Tue Sep 1 04:19:43 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: q7 2014 MST From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > why does 1/2 round down? ( i'm assuming it will always round down) is > it the norm in most languages and is there a good reason for it, besides convention? > > > edit > > it seems evem 9/10 rounds down... Are you describing the right question? Q7 doesn't have any use of rounding in it. C doesn't have any rounding in its arithmetic operators - the only time you see any rounding in C is when you ask printf() to format a floating point number to a certain number of decimal places. (still unrelated to Q7, but you may be thinking of 'truncation' - throwing away the decimal part of a floating point number ?) From graven01@csse.uwa.edu.au Tue Sep 1 09:00:25 2015 Date: Tue Sep 1 09:00:25 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Char arrays From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none char a[3] = "abc" ; printf("a = %s ", a); compiles and runs, without the '\0' is this still a string or just an array of characters. when i run it i get a=abc(with a funny bulls eye symbol here) what is that? From 00014979@csse.uwa.edu.au Tue Sep 1 09:13:14 2015 Date: Tue Sep 1 09:13:14 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Char arrays From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > char a[3] = "abc" ; > printf("a = %s ", a); You've defined an array of exactly 3 characters. You've neither provided nor requested a NULL-byte. > when i run it i get > a=abc(with a funny bulls eye symbol here) > what is that? It's the character immediately following the 'c' in memory (just a random, unspecified byte in memory that has not been initialised), and obviously not a NULL-byte. From graven01@csse.uwa.edu.au Tue Sep 1 09:28:44 2015 Date: Tue Sep 1 09:28:44 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Char arrays From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > char a[3] = "abc" ; > > printf("a = %s ", a); > > You've defined an array of exactly 3 characters. > You've neither provided nor request a NULL-byte. > what to you mean by request here? if a was [4] it would automatically add the null byte. and provide it how "abc'\0'" ? > > > when i run it i get > > a=abc(with a funny bulls eye symbol here) > > what is that? > > It's the character immediately following the 'c' (just a random, unspecified byte in memory > that has not been initialised), and obviously not a NULL-byte. im still not sure why it is being printed out though, a[0] = 'a' a[1] = 'b' a[2] ='c' there is no null terminating character. so why can i print it out with %s, and why would it go out of bounds of the array and grab an extra byte in memory. From graven01@csse.uwa.edu.au Tue Sep 1 09:50:18 2015 Date: Tue Sep 1 09:50:18 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Question 16 Mid Semester Test. From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none A. fgets reads all the bytes in the file up to the next newline character. why is this false? or is it that B is just "more true" as you stated yesterday ? "The C library function char *fgets(char *str, int n, FILE *stream) reads a line from the specified stream and stores it into the string pointed to by str. It stops when either (n-1) characters are read, the newline character is read, or the end-of-file is reached, whichever comes first." - From- http://www.tutorialspoint.com/c_standard_library/c_function_fgets.htm From dewarj02@csse.uwa.edu.au Tue Sep 1 10:59:52 2015 Date: Tue Sep 1 10:59:52 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.128 Subject: Project 1 partner From: "Jye Dewar" <21488841@student.uwa.edu.au> X-smilie: none X-img: none Hey, I am looking for a partner too. Email me at 21488841@student.uwa.edu.au if anyone needs one :) From 00014979@csse.uwa.edu.au Tue Sep 1 12:06:46 2015 Date: Tue Sep 1 12:06:46 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Char arrays From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > what to you mean by request here? if a was [4] it would automatically add the null byte. > and provide it how "abc'\0'" ? No; if you DIDN'T provide an array size, and let the compiler determine the require space, you'd be requesting that the NULL_byte be added. > im still not sure why it is being printed out though, > > a[0] = 'a' a[1] = 'b' a[2] ='c' there is no null terminating character. so why can i print it out > with %s, and why would it go out of bounds of the array and grab an extra byte in memory. The array size is not known/retained at runtime (that's why we need a strlen() function). printf...%s...) just keeps printing successive characters until it finds a NULL-byte, or until it attempts to access memory not owned by your process. From jennib03@csse.uwa.edu.au Tue Sep 1 12:07:23 2015 Date: Tue Sep 1 12:07:23 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.227.80 Subject: q7 2014 MST From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none I am stumped by this question as well. A quick Google search tells me that % will return a 1 if there is a remainder, and 0 for no remainder (i.e., they are the only possible returned results [1 || 0]). so:- 2%2 == 0; 3%2 == 1; 4%2 == 0; 5%3 == 1; // Note that it does not equal 2, which would be the actual remainder of 5/3. Is this accurate Chris? And if so, why is the answer not D. 6? For the 11 iterations: 0 - I honestly have no idea how it handles 0, please help? 1 - 1/2 = 1r. ∴ 1%2 == 1, and it moves on 2 - 2%2 == 0, but 2/3 == 2r, ∴ 2%3 == 1, and it continues back to the loop 3 - 3%2 == 1 (2r) 4 - Again, 4%2 == 0, but returns 1 for 4%3? 5 - Returns 1 for both checks (if it gets to the second) 6 - Returns 0 for both, so would be printed? 7 - Returns 1 for both 8 - 8%2 == 0, but 8%3 == 1. 9 - 9%2 == 1 10 - 10%2 == 0, but 10%3 == 1 How far of the track am I going here? I really feel like I'm missing something obvious that I should know. From 00014979@csse.uwa.edu.au Tue Sep 1 12:08:04 2015 Date: Tue Sep 1 12:08:04 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Question 16 Mid Semester Test. From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > A. fgets reads all the bytes in the file up to the next newline character. > > why is this false? or is it that B is just "more true" as you stated yesterday ? It cannot (always) be true if there's no newline character in the file; it's only true in some circumstances. From leongd02@csse.uwa.edu.au Tue Sep 1 12:11:28 2015 Date: Tue Sep 1 12:11:28 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.245.157 Subject: Question 16 Mid Semester Test. From: "Dylan Leong" <21485566@student.uwa.edu.au> X-smilie: none X-img: none not sure if i'm completely correct about this but here goes i think the part about fgets where "It stops when either (n-1) characters are read," is the key point here, because the question asks "Which of the following statements about the call to the fgets function is always true?". so having an integer n less than the number of characters before the newline means that fgets won't "always" read up to the next newline character. From 00014979@csse.uwa.edu.au Tue Sep 1 12:11:35 2015 Date: Tue Sep 1 12:11:35 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: q7 2014 MST From: "Christopher McDonald" X-smilie: none X-img: none "Benjamin Jennings" <21460003@student.uwa.edu.au> wrote: > I am stumped by this question as well. A quick Google search tells me that % will return a 1 if > there is a remainder, and 0 for no remainder (i.e., they are the only possible returned results This initial statement is wrong. The expression (a % b) returns the remainder when b is divided into a. If b is a factor of a, or a a multiple of b, then result will be 0. Otherwise the result will be in the range [0 .. a-1 ] From jennib03@csse.uwa.edu.au Tue Sep 1 12:12:15 2015 Date: Tue Sep 1 12:12:15 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.227.80 Subject: fork() From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > "David Chinnery" <21142701@student.uwa.edu.au> wrote: > > > Got me too even after I wrote a test program it failed to compile on a windows machine ( but it > > worked on Linux). I said C. ( 4x hello) I guess the lesson here is to read the actual question. > > If it said "What would the output be under Linux" then it would be a different story. > > No, don't try and read too much into the question - it's not trying to be tricky. > > The question asks "If the above code executes successfully....", > so the code must have already compiled and linked successfully to get that far. But if the questions asks "If the above code executes successfully..." and we can therefore assume that it compiled fine - why wouldn't we know sorry? Surely the OS supports the call and therefore it would be four? From jennib03@csse.uwa.edu.au Tue Sep 1 12:19:50 2015 Date: Tue Sep 1 12:19:50 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.227.80 Subject: q7 2014 MST From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > "Benjamin Jennings" <21460003@student.uwa.edu.au> wrote: > > > I am stumped by this question as well. A quick Google search tells me that % will return a 1 if > > there is a remainder, and 0 for no remainder (i.e., they are the only possible returned results > > This initial statement is wrong. > > The expression (a % b) returns the remainder when b is divided into a. > If b is a factor of a, or a a multiple of b, then result will be 0. > Otherwise the result will be in the range [0 .. a-1 ] Okay, thanks for the help but I am still stuck. How exactly should we read "if ((i%2) == 1) { continue; }"? Could you please briefly break it down? From motts02@csse.uwa.edu.au Tue Sep 1 12:20:35 2015 Date: Tue Sep 1 12:20:35 2015 Edit: Tue Sep 1 12:21:37 2015 To: help2002@csse.uwa.edu.au Received: from 27.33.96.171 Subject: q7 2014 MST From: "Stephen Mott" <21140413@student.uwa.edu.au> X-smilie: none X-img: none I figured out what it was doing by getting running the code and printing where it was getting caught in the if statements 0 was printed 1 caught by mod 2 2 was printed 3 caught by mod 2 4 caught by mod 3 5 caught by mod 2 6 was printed 7 caught by mod 2 8 was printed 9 caught by mod 2 10 caught by mod 3 Where if it gets caught the Continue command sends it back up the loop to try the next iteration From fetzee01@csse.uwa.edu.au Tue Sep 1 12:24:33 2015 Date: Tue Sep 1 12:24:33 2015 Edit: Tue Sep 1 12:25:18 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: q7 2014 MST From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none >Okay, thanks for the help but I am still stuck. >How exactly should we read "if ((i%2) == 1) { continue; }"? Could you please briefly break it down? read the lecture notes. http://teaching.csse.uwa.edu.au/units/CITS2002/lectures/lecture03/07.html From jennib03@csse.uwa.edu.au Tue Sep 1 12:34:06 2015 Date: Tue Sep 1 12:34:06 2015 Edit: Tue Sep 1 12:43:41 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.227.80 Subject: q7 2014 MST From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none "Stephen Mott" <21140413@student.uwa.edu.au> wrote: > I figured out what it was doing by getting running the code and printing where it was getting caught > in the if statements > > > 0 was printed > 1 caught by mod 2 > 2 was printed > 3 caught by mod 2 > 4 caught by mod 3 > 5 caught by mod 2 > 6 was printed > 7 caught by mod 2 > 8 was printed > 9 caught by mod 2 > 10 caught by mod 3 > > Where if it gets caught the Continue command sends it back up the loop to try the next iteration Thanks Scott and anon, I understand what continue/break does, sorry i shouldn't have included that in the question I had. I've been using them for years w/o a problem. It is the "( i mod x ) == y" in the if statement that I am uncertain on. EDIT: I got it now, just entered the statements into a calculator and drew up a table. Much easier to follow now. x x%2 x%3 +---+---+---+ | 0 | 0 | 0 | +---+---+---+ | 1 | 1 | 1 | +---+---+---+ | 2 | 0 | 2 | +---+---+---+ | 3 | 1 | 0 | etc. ∴ 0 prints, 1 doesn't, 2 does (because 2%3==2, not 1), 3 doesn't, etc. Sorry for the confusion. Thanks for the help! From graven01@csse.uwa.edu.au Tue Sep 1 12:43:09 2015 Date: Tue Sep 1 12:43:09 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: q7 2014 MST From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none i honestly went to a kindergarten website on remainders to realize how dumb i was. 0 % 2, 0 lollies divided by 2 kids, it wont fit as a whole number so it doesn't dry and there is 0r 1 % 2, 1 lollies div 2 kids, again (int) cant be split so it wont go, so the one lolly is left 2 % 2, 2 lollies, 2 kids each kids get a lolly and there are none left 0r 3 % 2 3 lollies, 2 kids, we can give one lollie to each kid but then we have one left that we cant split up.. so 1r etc etc only prints out when the remainder does not equal 1 this helped me because i'm a preschooler. From jennib03@csse.uwa.edu.au Tue Sep 1 12:45:13 2015 Date: Tue Sep 1 12:45:13 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.227.80 Subject: q7 2014 MST From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > this helped me because i'm a preschooler. Me too apparently! From graven01@csse.uwa.edu.au Tue Sep 1 12:50:01 2015 Date: Tue Sep 1 12:50:01 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Char arrays From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > The array size is not known/retained at runtime (that's why we need a strlen() function). > printf...%s...) just keeps printing successive characters until it finds a NULL-byte, or until it attempts to > access memory not owned by your process. so lets say the next bit of memory happened to be a string it would carry on reading until the null byte? doesn't it know that the next bit of memory isn't part of the process? doesn't that a security flaw if can can read random bits of memory? or was that random bullseye symbol actual a bit of memory in my process then it found something outside so it didn't print it ? From heinsm01@csse.uwa.edu.au Tue Sep 1 13:40:02 2015 Date: Tue Sep 1 13:40:02 2015 To: help2002@csse.uwa.edu.au Received: from 153.142.247.66 Subject: Char arrays From: "Matthew Heinsen Egan" <10430227@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > "Christopher McDonald" wrote: > > > > The array size is not known/retained at runtime (that's why we need a strlen() function). > > printf...%s...) just keeps printing successive characters until it finds a NULL-byte, or until it attempts to > > access memory not owned by your process. > > so lets say the next bit of memory happened to be a string it would carry on reading until the null byte? doesn't it > know that the next bit of memory isn't part of the process? doesn't that a security flaw if can can read random bits > of memory? > > or was that random bullseye symbol actual a bit of memory in my process then it found something outside so it didn't > print it ? It would be a security flaw if a process could read memory that it didn't own. If the process attempts to access memory that it doesn't own, our modern operating systems will deny that memory access. The operating system notifies the process of this. The default behaviour for C programs is usually to terminate the process. On the other hand, the process can access memory that it does own. So the random bullseye symbol would be in the memory owned by your process, immediately following the character array. The printf likely stopped reading the string because it encountered a NULL-byte soon afterwards. The bullseye symbol and the NULL-byte are not necessarily part of another string - they are just bytes of memory which are being interpreted as characters by the printf function in this instance. That memory might have some other meaning in the program (e.g. both bytes could be part of an integer). From jennib03@csse.uwa.edu.au Tue Sep 1 14:10:26 2015 Date: Tue Sep 1 14:10:26 2015 To: help2002@csse.uwa.edu.au Received: from 1.126.48.16 Subject: Project 1 partner From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none How disadvantaged are we going to be if we decide to go it alone for project 1? From porebm01@csse.uwa.edu.au Tue Sep 1 14:22:46 2015 Date: Tue Sep 1 14:22:46 2015 Edit: Tue Sep 1 14:24:46 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.207.42 Subject: Few quiries about the mid test solution From: "Martin Porebski" <21498791@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > When I compile and run: > > char array1[5] = "hello"; > > int main(int argc, char *argv[]) > { > char array2[5] = "hello"; > > printf("%i %i\n", (int)strlen(array1), (int)strlen(array2)); > return 0; > } > > the output is '5 11' on my OS-X desktop, and '5 33' on my Linux box. > It just all depends on where the next NULL-byte is. > > Which 'buffer' do you mean? Why is it 11 or 33? From 00014979@csse.uwa.edu.au Tue Sep 1 14:24:43 2015 Date: Tue Sep 1 14:24:43 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Few quiries about the mid test solution From: "Christopher McDonald" X-smilie: none X-img: none "Martin Porebski" <21498791@student.uwa.edu.au> wrote: > Why is it 11 or 33? Because that's just how many bytes it took the strlen() function to find the first NULL-byte. The memory physically after the string had not been initialised. From graven01@csse.uwa.edu.au Tue Sep 1 14:37:21 2015 Date: Tue Sep 1 14:37:21 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.98.213 Subject: Char arrays From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none Fantastic, thanks for taking the time to explain it, much appreciated. From 00014979@csse.uwa.edu.au Tue Sep 1 16:41:30 2015 Date: Tue Sep 1 16:41:30 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.58.73 Subject: Project 1 partner From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > How disadvantaged are we going to be if we decide to go it alone for project 1? Honestly, impossible to say, as I don;t know who you are or your level of experience. If a first-time programmer (we have a few in the unit, despite warnings) then I'd seriously discourage you working alone. From graven01@csse.uwa.edu.au Tue Sep 1 20:14:52 2015 Date: Tue Sep 1 20:14:52 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Test From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none how did people feel about the test? i notice there were duplicate questions from last years test which was nice, i messed up q8 (for SUM reason, i was answering the value of sum, instead of i) i messed up 13. to put 5 instead of 4, because of the pre increment of y. i think that was an easy mark i wasted. also i'm sot sure what the answer for 20 was, i guessed A. From fetzee01@csse.uwa.edu.au Tue Sep 1 20:32:54 2015 Date: Tue Sep 1 20:32:54 2015 Edit: Tue Sep 1 20:34:36 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: Test From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > how did people feel about the test? > > i notice there were duplicate questions from last years test which was nice, > > i messed up q8 (for SUM reason, i was answering the value of sum, instead of i) > > i messed up 13. to put 5 instead of 4, because of the pre increment of y. i think that > was an easy mark i wasted. > > also i'm sot sure what the answer for 20 was, i guessed A. Don't worry prone to make these types of mistakes! (as did I) . Although the test was 100% fair I can say that From nelsoj07@csse.uwa.edu.au Tue Sep 1 20:59:07 2015 Date: Tue Sep 1 20:59:07 2015 To: help2002@csse.uwa.edu.au Received: from 60.228.44.170 Subject: Test From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Maybe I'll feel differently when marks are released, but I found it OK, there were none that were completely new to me, but still quite a few I found pretty tricky or wasn't sure of the answers too! Keen to get it back and see how it went! From chowda01@csse.uwa.edu.au Tue Sep 1 22:30:21 2015 Date: Tue Sep 1 22:30:21 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.112.22 Subject: Project 1 From: "Anirban Chowdhury" <21432966@student.uwa.edu.au> X-smilie: none X-img: none When will the project be released? I thought it was today. Thanks From fetzee01@csse.uwa.edu.au Tue Sep 1 22:33:24 2015 Date: Tue Sep 1 22:33:24 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: Project 1 From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none "1st project will not be available until very late Tuesday", index page. From jennib03@csse.uwa.edu.au Tue Sep 1 23:10:02 2015 Date: Tue Sep 1 23:10:02 2015 Edit: Tue Sep 1 23:16:56 2015 To: help2002@csse.uwa.edu.au Received: from 1.127.48.168 Subject: Test From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > i messed up q8 (for SUM reason, i was answering the value of sum, instead of i) Damn! As did I.. that seems a little dirty tbh. I guess it just is what it is. I think the question could have been asked just as effectively with ellipses in place of sum = sum + i though. For 13, I put D because I remember Chris going through the same code on different architecture in reference to i++, and he was emphasising we should use i = i + 1; instead. But maybe it was another "trick" question or something. If not D, I would have gone with 5 as well though. I wonder if we will go through the answers at some point. From jennib03@csse.uwa.edu.au Wed Sep 2 00:06:02 2015 Date: Wed Sep 2 00:06:02 2015 To: help2002@csse.uwa.edu.au Received: from 1.127.48.168 Subject: Project 1 From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > "1st project will not be available until very late Tuesday", index page. Well I waited for late Tuesday to pass, but it's sleep time for some! Hopefully it will be up in the morning so we can see what we are up against. :) From mcfald01@csse.uwa.edu.au Wed Sep 2 00:42:53 2015 Date: Wed Sep 2 00:42:53 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.158.58 Subject: Test From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none Seemed to be a lot of trick questions, which is good I suppose but it makes you pay close detail and know certain nuances Either that or I'm wrong and got a lot of obvious questions wrong From graven01@csse.uwa.edu.au Wed Sep 2 07:23:08 2015 Date: Wed Sep 2 07:23:08 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Test From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none "Benjamin Jennings" <21460003@student.uwa.edu.au> wrote: > ANONYMOUS wrote: > > > i messed up q8 (for SUM reason, i was answering the value of sum, instead of i) > > Damn! As did I.. that seems a little dirty tbh. I guess it just is what it is. I think the > question could have been asked just as effectively with ellipses in place of sum = sum + i though. > > For 13, I put D because I remember Chris going through the same code on different architecture in reference to > i++, and he was emphasising we should use i = i + 1; instead. But maybe it was another "trick" question or > something. If not D, I would have gone with 5 as well though. I wonder if we will go through the answers at some point. yeah same for me with question 8, comprehension test perhaps ? it felt a bit like the old, as i was going to st ives i met a man with seven wives his seven wives.......trick a bit rough if you ask me, i thought the rest was pretty standard though a couple i got wrong going back through it, it would be nice if Chris went through the answers at some point maybe just the ones that were answered wrong the most. From chinnd01@csse.uwa.edu.au Wed Sep 2 07:55:47 2015 Date: Wed Sep 2 07:55:47 2015 To: help2002@csse.uwa.edu.au Received: from 124.182.9.1 Subject: Test From: "David Chinnery" <21142701@student.uwa.edu.au> X-smilie: none X-img: none "Benjamin Jennings" <21460003@student.uwa.edu.au> wrote: > ANONYMOUS wrote: > > > i messed up q8 (for SUM reason, i was answering the value of sum, instead of i) > > Damn! As did I.. that seems a little dirty tbh. I guess it just is what it is. I think the > question could have been asked just as effectively with ellipses in place of sum = sum + i though. > > For 13, I put D because I remember Chris going through the same code on different architecture in reference to > i++, and he was emphasising we should use i = i + 1; instead. But maybe it was another "trick" question or > something. If not D, I would have gone with 5 as well though. I wonder if we will go through the answers at some point. I think its more of a prefix/postfix question. In a postfix ( x++ ) the value is determined BEFORE the variable is increased, prefix is the other way round. So I think the answer is 7 - 3 = B. 4. From 00014979@csse.uwa.edu.au Wed Sep 2 08:19:48 2015 Date: Wed Sep 2 08:19:48 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Test From: "Christopher McDonald" X-smilie: none X-img: none "Benjamin Jennings" <21460003@student.uwa.edu.au> wrote: > ANONYMOUS wrote: > > > i messed up q8 (for SUM reason, i was answering the value of sum, instead of i) > > Damn! As did I.. that seems a little dirty tbh. I guess it just is what it is. I think the > question could have been asked just as effectively with ellipses in place of sum = sum + i though. Maybe so, but I fear that you missed the 'real trick' in the question. :-( Try it: void increment(int i) { i++; } void go(void) { int i = 0; int sum = 0; for (i = 0; i < 10; increment(i)) { sum = sum + i; } printf("Final value of i = %d\n", i); } From liaoj02@csse.uwa.edu.au Wed Sep 2 08:31:23 2015 Date: Wed Sep 2 08:31:23 2015 To: help2002@csse.uwa.edu.au Received: from 43.252.114.150 Subject: Test From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > "Benjamin Jennings" <21460003@student.uwa.edu.au> wrote: > > > ANONYMOUS wrote: > > > > > i messed up q8 (for SUM reason, i was answering the value of sum, instead of i) > > > > Damn! As did I.. that seems a little dirty tbh. I guess it just is what it is. I think the > > question could have been asked just as effectively with ellipses in place of sum = sum + i though. > > Maybe so, but I fear that you missed the 'real trick' in the question. :-( > Try it: > > void increment(int i) > { > i++; > } > > void go(void) > { > int i = 0; > int sum = 0; > > for (i = 0; i < 10; increment(i)) > { > sum = sum + i; > } > printf("Final value of i = %d\n", i); > } It will be a loop without break? Is it because the variable i in increament function is actually not the same as the i in for loop.? From lic31@csse.uwa.edu.au Wed Sep 2 08:49:48 2015 Date: Wed Sep 2 08:49:48 2015 To: help2002@csse.uwa.edu.au Received: from 60.228.192.248 Subject: Test From: "Cikang Li" <21448107@student.uwa.edu.au> X-smilie: none X-img: none It won't have any effect on i since the function does not return i. From graven01@csse.uwa.edu.au Wed Sep 2 08:56:35 2015 Date: Wed Sep 2 08:56:35 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Test From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none > Maybe so, but I fear that you missed the 'real trick' in the question. :-( > Try it: > > void increment(int i) > { > i++; > } > > void go(void) > { > int i = 0; > int sum = 0; > > for (i = 0; i < 10; increment(i)) > { > sum = sum + i; > } > printf("Final value of i = %d\n", i); > } I see that increment doesn't return anything it just increments i, so the final value of i is 0, but technically its running an infinite loop, and infinity means forever and ever so i will never have a final value? does that mean i can have D as the right answer, even though it was for the wrong reasons ? :D From 00014979@csse.uwa.edu.au Wed Sep 2 09:03:55 2015 Date: Wed Sep 2 09:03:55 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Test From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > does that mean i can have D as the right answer, even though it was for the wrong reasons ? :D Surely you carefully selected D for the right reasons :-) From graven01@csse.uwa.edu.au Wed Sep 2 09:15:17 2015 Date: Wed Sep 2 09:15:17 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Test From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > does that mean i can have D as the right answer, even though it was for the wrong reasons ? :D > > Surely you carefully selected D for the right reasons :-) HAHAHAHHAHAHAHA No, Its because i thought i was answering for Sum (which still would have been wrong) but you don't know who i am so ;P Free marks for me From radham02@csse.uwa.edu.au Wed Sep 2 09:58:07 2015 Date: Wed Sep 2 09:58:07 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.118.76 Subject: Project 1 partner From: "Mugundan Radhakrishnan" <21493083@student.uwa.edu.au> X-smilie: none X-img: none If anyone is still after a project partner, send me an email at 21493083@student.uwa.edu.au. If the project proves to be a stressful experience I'll shout you hot chocolate/coffee/tea. From phans02@csse.uwa.edu.au Wed Sep 2 11:54:59 2015 Date: Wed Sep 2 11:54:59 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.108.31 Subject: Project 1 partner From: "Steven Phan" <21521532@student.uwa.edu.au> X-smilie: none X-img: none Hi, I'm looking for a project partner as well. Email me at 21521532@student.uwa.edu.au :) From tayi02@csse.uwa.edu.au Wed Sep 2 13:42:50 2015 Date: Wed Sep 2 13:42:50 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.157.168 Subject: Project 1 partner From: "Ian Tay" <20939902@student.uwa.edu.au> X-smilie: none X-img: none Hi, I'm looking for a project partner to work with. Please email me at 20939902@student.uwa.edu.au From vanded04@csse.uwa.edu.au Wed Sep 2 13:42:56 2015 Date: Wed Sep 2 13:42:56 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.184.79 Subject: Project 1 question From: "Damon Van Der Linde" <21506136@student.uwa.edu.au> X-smilie: none X-img: none Are we required to check the data types of the arguments passed and display an appropriate error message if it fails? From 00014979@csse.uwa.edu.au Wed Sep 2 13:45:41 2015 Date: Wed Sep 2 13:45:41 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Project 1 question From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Are we required to check the data types of the arguments passed and display an appropriate > error message if it fails? (politely) what do you think a program with incorrect arguments *should* do (because that's the answer)? Also, don't forget that the actual datatype of the command-line arguments are all just character arrays (strings), so you can only check them once you've converted them to what you hope they represent. From nelsoj07@csse.uwa.edu.au Wed Sep 2 14:44:23 2015 Date: Wed Sep 2 14:44:23 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.235.222 Subject: Project 1 question From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: question.png X-img: none Hey Chris, Just wondering for the assignment, are we expected to use Haversines formula to calculate distance like done the other day in the Tutorial? If so what radius for the Earth should we use, there's a few values on Wikipedia and other resources and the value I used at home before the tute was just off the value you had, and don't want to get something like that wrong! From 00014979@csse.uwa.edu.au Wed Sep 2 14:52:51 2015 Date: Wed Sep 2 14:52:51 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Project 1 question From: "Christopher McDonald" X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > Just wondering for the assignment, are we expected to use Haversines formula to calculate distance like done > the other day in the Tutorial? If so what radius for the Earth should we use, there's a few values on Fair question; I guess I was *anticipating* that everyone would just choose the Tutorial solution. The automatic marker will certainly have some slack in its numerical comparisons (we're used to the need for this!), so unless your formula is different than by more than (guessing) 100metres, you should be OK. Of note, some of the lat/lon pairs in the TransPerth data are 'precise' to 15-decimal places! See what this webpage says about that: http://gis.stackexchange.com/questions/8650/how-to-measure-the-accuracy-of-latitude-and-longitude From jennib03@csse.uwa.edu.au Wed Sep 2 15:39:15 2015 Date: Wed Sep 2 15:39:15 2015 To: help2002@csse.uwa.edu.au Received: from 1.127.48.168 Subject: Test From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none "David Chinnery" <21142701@student.uwa.edu.au> wrote: > I think its more of a prefix/postfix question. In a postfix ( x++ ) the value is determined BEFORE the variable is increased, > prefix is the other way round. So I think the answer is 7 - 3 = B. 4. Isn't that the point Chris was trying to make? That how postfix/prefix is handled is platform architecture dependant? "Christopher McDonald" wrote: > Maybe so, but I fear that you missed the 'real trick' in the question. :-( > Try it: Well that's even further irony I suppose, as I was initially focusing on that - trying to determine if it would even get to i=10 in the loop. Regardless, I should never have assumed that the output would have anything to do with calculations being performed in the looped block, even if it does seem like the obvious thing ;) (I also "carefully selected" D anyway. I had decided that the sum was way higher than the options given, and I was fairly certain the scope of the i variable was going to cause some form of problems - now I know what the problems are as well!) :/ From jennib03@csse.uwa.edu.au Wed Sep 2 15:52:49 2015 Date: Wed Sep 2 15:52:49 2015 To: help2002@csse.uwa.edu.au Received: from 1.127.48.168 Subject: Project 1 partner From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > If anyone is still after a project partner, send me an email at 21493083@student.uwa.edu.au. If > the project proves to be a stressful experience I'll shout you hot chocolate/coffee/tea. This person knows how to attract project partners! +1 From pratia02@csse.uwa.edu.au Wed Sep 2 16:20:42 2015 Date: Wed Sep 2 16:20:42 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.241.1 Subject: Project 1 partner From: "Aashay Pratish" <21424509@student.uwa.edu.au> X-smilie: none X-img: none Hello, I am looking for a partner. My e-mail address is 21424509@student.uwa.edu.au Please feel free to contact me. From graven01@csse.uwa.edu.au Wed Sep 2 16:54:10 2015 Date: Wed Sep 2 16:54:10 2015 To: help2002@csse.uwa.edu.au Received: from 58.169.252.96 Subject: Project 1 partner From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none "Benjamin Jennings" <21460003@student.uwa.edu.au> wrote: > ANONYMOUS wrote: > > > If anyone is still after a project partner, send me an email at 21493083@student.uwa.edu.au. If > > the project proves to be a stressful experience I'll shout you hot chocolate/coffee/tea. > > This person knows how to attract project partners! +1 or they are good at outsourcing for minimum wage! From jennib03@csse.uwa.edu.au Wed Sep 2 17:18:30 2015 Date: Wed Sep 2 17:18:30 2015 To: help2002@csse.uwa.edu.au Received: from 1.127.48.168 Subject: Project 1 partner From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > or they are good at outsourcing for minimum wage! Aha! You raise a good point. Is the amount of hot drinks negotiable? From weinej01@csse.uwa.edu.au Wed Sep 2 23:00:57 2015 Date: Wed Sep 2 23:00:57 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.89.12 Subject: Project 1 partner From: "Jake Weiner" <20749646@student.uwa.edu.au> X-smilie: none X-img: none Hate to repeat what those who have come before have said but if anyone still needs a partner hit me up at 20749646@student.uwa.edu.au From bullof01@csse.uwa.edu.au Thu Sep 3 09:54:59 2015 Date: Thu Sep 3 09:54:59 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.83 Subject: Project 1 partner From: "Fraser Bullock" <21299527@student.uwa.edu.au> X-smilie: none X-img: none I was mostly planning on tackling this one alone, but that's no fun. If you are some- what competent (this is not your first coding unit[I dont include 2401]) and free tomorrow, we can bash it out in a day, maybe half. From bullof01@csse.uwa.edu.au Thu Sep 3 10:05:26 2015 Date: Thu Sep 3 10:05:26 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.83 Subject: Test From: "Fraser Bullock" <21299527@student.uwa.edu.au> X-smilie: none X-img: none As soon as I saw the first line "void increment(int i)" I knew the code would be broken. You have a function named increment that doesn't return the increment int value... Something that experience tells you. From bradfj01@csse.uwa.edu.au Thu Sep 3 10:24:44 2015 Date: Thu Sep 3 10:24:44 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.71.120 Subject: Test From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none If it makes any of you feel better, I miss read "Which one of the following is a valid c99 loop statement", and I read it as "a invalid c99 loop statement". So much facepalm. From nelsoj07@csse.uwa.edu.au Thu Sep 3 10:50:48 2015 Date: Thu Sep 3 10:50:48 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.235.222 Subject: Project 1 partner From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none "Fraser Bullock" <21299527@student.uwa.edu.au> wrote: > I was mostly planning on tackling this one alone, but that's no fun. If you are some- > what competent (this is not your first coding unit[I dont include 2401]) and free > tomorrow, we can bash it out in a day, maybe half. ^ This guy. I'm impressed. Taken, but impressed From tayi02@csse.uwa.edu.au Thu Sep 3 11:30:10 2015 Date: Thu Sep 3 11:30:10 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.157.168 Subject: Project 1 partner From: "Ian Tay" <20939902@student.uwa.edu.au> X-smilie: none X-img: none "Jake Weiner" <20749646@student.uwa.edu.au> wrote: > Hate to repeat what those who have come before have said but if anyone still needs a > partner hit me up at 20749646@student.uwa.edu.au Sent you an email... From batesj05@csse.uwa.edu.au Thu Sep 3 13:57:37 2015 Date: Thu Sep 3 13:57:37 2015 To: help2002@csse.uwa.edu.au Received: from 103.6.210.174 Subject: Project 1 partner From: "Johnathon Bates" <20942221@student.uwa.edu.au> X-smilie: none X-img: none Hi, I'm looking for a partner Email me on s20942221@student.uwa.edu.au Cheers guys From abusha02@csse.uwa.edu.au Thu Sep 3 14:19:36 2015 Date: Thu Sep 3 14:19:36 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.195.4 Subject: Midsem results From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none Hi. When will mid-sem results be released? I thought the "advantage of multi choice tests is that the results can be uploaded within 2 days"(Chris McDonald, 2015). From 00014979@csse.uwa.edu.au Thu Sep 3 14:22:06 2015 Date: Thu Sep 3 14:22:06 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Midsem results From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hi. When will mid-sem results be released? I thought the "advantage of multi choice > tests is that the results can be uploaded within 2 days"(Chris McDonald, 2015). Within 2 days of what? Uniprint 'promise' to return them within 48 hours of collection - at 1.30pm today we reminded them to come and collect them. From newmal01@csse.uwa.edu.au Thu Sep 3 16:30:35 2015 Date: Thu Sep 3 16:30:35 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.130 Subject: fscanf From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none hi i am trying use fscanf to access the data from the stops.txt but i am recieving the error segmentation fault:11 ? From 00014979@csse.uwa.edu.au Thu Sep 3 16:34:47 2015 Date: Thu Sep 3 16:34:47 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: fscanf From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > hi i am trying use fscanf to access the data from the stops.txt > but i am recieving the error > segmentation fault:11 > ? You've clearly not provided enough information to diagnose it. Why not try assert(), as introduced in today's lecture? From graven01@csse.uwa.edu.au Thu Sep 3 16:50:53 2015 Date: Thu Sep 3 16:50:53 2015 To: help2002@csse.uwa.edu.au Received: from 120.21.140.252 Subject: Data query From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none 0,,10000,10000,"Albany Hwy After Armadale Rd","",-32.1479054960,116.0201957650,4 from stops.txt ^ so this whole thing is the unique stop id ? whats with the double comma? also is all the data in order on the General Transit Feed Specification Reference page ? i take it being perth they only included the required data . From 00014979@csse.uwa.edu.au Thu Sep 3 16:59:06 2015 Date: Thu Sep 3 16:59:06 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Data query From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > 0,,10000,10000,"Albany Hwy After Armadale Rd","",-32.1479054960,116.0201957650,4 > > from stops.txt > > ^ > so this whole thing is the unique stop id ? whats with the double comma? They are comma separated fields. The unique stop_id in that example is 10000. See https://developers.google.com/transit/gtfs/reference?hl=en#stops_fields Double comma indicates an empty/optional field. > also is all the data in order on the General Transit Feed Specification Reference page ? > i take it being perth they only included the required data . Unsure what you mean 'in order' ? The first line of each datafile gives you the order of the columns (unsure why it's not documented in that order on the webpage). From newmal01@csse.uwa.edu.au Thu Sep 3 17:13:10 2015 Date: Thu Sep 3 17:13:10 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.130 Subject: Segmentation Fault 11 From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none for some reason in the following code i am recieveing the error segmetation fault 11 ? #include #include #define STOPS "/Users/21107195/cits2002/google_transit/stops" int main(int argc, char* argv[]) { FILE *fp = fopen(STOPS,"r"); char line[BUFSIZ]; while(fgets(line, sizeof line, fp)!=NULL) { printf("%s",line); } fclose(fp); } From 00014979@csse.uwa.edu.au Thu Sep 3 17:15:49 2015 Date: Thu Sep 3 17:15:49 2015 Edit: Thu Sep 3 17:16:35 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Segmentation Fault 11 From: "Christopher McDonald" X-smilie: none X-img: none Filename is stops.txt ?? i.e. you didn't check if your call to fopen() actually succeeded. From abusha02@csse.uwa.edu.au Thu Sep 3 17:47:32 2015 Date: Thu Sep 3 17:47:32 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.195.4 Subject: Efficiency in project solution From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none Hi. I was just wondering, will the auto testing time out after a certain period of time. I am approaching a working solution, but as of now, it is quite inefficient. I aim to increase efficiency, obviously, and I understand that we will get marked down for inefficient solutions, but I'm just wondering if the auto-tester will timeout after a certain number of seconds. As of now, my solution seems like it'll take about 10 seconds (something I aim to change), so will the auto-tester just timeout and give me 0? From jennib03@csse.uwa.edu.au Thu Sep 3 17:57:39 2015 Date: Thu Sep 3 17:57:39 2015 To: help2002@csse.uwa.edu.au Received: from 1.126.48.9 Subject: Efficiency in project solution From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none I got the impression from the lecture today that Chris is expecting solutions to not just display results immediately. I'd guess that 10 seconds would be fine - though I'm also hoping to get it down to a minimum possible time. From fetzee01@csse.uwa.edu.au Thu Sep 3 18:22:52 2015 Date: Thu Sep 3 18:22:52 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: lecture audio fail From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none Just letting you know, the audio appears to have failed in the recording of today's lecture. Hopefully this is a one time situation. From zhangj47@csse.uwa.edu.au Thu Sep 3 20:05:38 2015 Date: Thu Sep 3 20:05:38 2015 To: help2002@csse.uwa.edu.au Received: from 203.59.209.195 Subject: Project 1 partner From: "Jin ZHANG" <21687443@student.uwa.edu.au> X-smilie: none X-img: none I'm looking for a project partner to work with. Please email me at 21687443@student.uwa.edu.au From 00014979@csse.uwa.edu.au Fri Sep 4 07:06:21 2015 Date: Fri Sep 4 07:06:21 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Efficiency in project solution From: "Christopher McDonald" X-smilie: none X-img: none The focus is not on efficiency, but on well-written, easy to read, code. The objective of the project is not to produce a solution that must execute in under N seconds (which would be dependent on a specific machine, and specific input data). A (not too) slow project can receive as many marks as a very fast one. The automatic marking script will timeout after some (lengthy) time, but only so that it traps projects that appear stuck in a never-ending loop (typically about 5% of submissions); the length of that timeout will be set/adjusted to ensure that the slowest terminating submission gets through. From phans02@csse.uwa.edu.au Fri Sep 4 15:37:49 2015 Date: Fri Sep 4 15:37:49 2015 To: help2002@csse.uwa.edu.au Received: from 120.145.190.89 Subject: Project 1 partner From: "Steven Phan" <21521532@student.uwa.edu.au> X-smilie: none X-img: none If anyone is still looking for a partner to work with, please email me at 21521532@student.uwa.edu.au From broers01@csse.uwa.edu.au Fri Sep 4 16:50:48 2015 Date: Fri Sep 4 16:50:48 2015 To: help2002@csse.uwa.edu.au Received: from 124.178.54.127 Subject: Project 1 partner From: "Sam Broere" <20923367@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > hey is anyone still looking for a partner to project 1 Hey I'm looking for a partner too. Email: 20923367@student.uwa.edu.au thanks! From newmal01@csse.uwa.edu.au Fri Sep 4 19:29:19 2015 Date: Fri Sep 4 19:29:19 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.130 Subject: sscanf() From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none im using the fgets fuction for each line of the stops.txt to access the data for each stop and im trying to print out a string with thestop name but no string will print also im trying to scan the stop_id and it is removing the 0s from the id number? while(fgets(line, sizeof line, stops)!=NULL){ if(count==2){ printf("%s\n",line); int location_type; int parent_station; char stop_id[100]; int stop_code; char stop_name[BUFSIZ]; char stop_desc[BUFSIZ]; double stop_lat; double stop_lon; int zone_id; sscanf(line,"%i,%i,%s,%i,%s,%s,%lf,%lf,%i",&location_type,&parent_station,stop_id,&stop_cod e,stop_name,stop_desc,&stop_lat,&stop_lon,&zone_id); sprintf("%s\n",stop_id);} count++;} From 00014979@csse.uwa.edu.au Fri Sep 4 19:40:55 2015 Date: Fri Sep 4 19:40:55 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: sscanf() From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > im using the fgets fuction for each line of the stops.txt to access the data for each stop > and im trying to print out a string with thestop name but no string will print also im > trying to scan the stop_id and it is removing the 0s from the id number? > I can't see why *nothing* is being printed(?), but your call to sprint() on the 2nd last line won't work, as you're not providing an array into which to format the result. > sprintf("%s\n",stop_id);} From newmal01@csse.uwa.edu.au Fri Sep 4 21:09:46 2015 Date: Fri Sep 4 21:09:46 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.130 Subject: scanf() conversition From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none does anyone know what the conversiton symbol for a negative decimal number is when using the function sscanf()? From newmal01@csse.uwa.edu.au Fri Sep 4 21:52:34 2015 Date: Fri Sep 4 21:52:34 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.130 Subject: parent station From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none are we required to use all the date from the text files? also fror the following lines of date how can i scan the parent-station? 0,13,10070,10070,"Victoria Park Transfer Stn Stand E","Victoria Park Transfer Stn",-31.9682883333333020,115.888946666667,1 0,,10071,10071,"Adelaide Tce Westend Causeway","Adelaide Tce / Westend Cway",-31.9615645625,115.8767979170,FTZ when in the first case the parent station is 13 and in the second case there is no parent station? From graven01@csse.uwa.edu.au Fri Sep 4 21:56:50 2015 Date: Fri Sep 4 21:56:50 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Data query From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none Is there any chance you could help me explain how the strtok function works; i read the how to use, but not sure how it actually works. I can split the fields up with a "," delimitter and able to print them all out nicely, however I'm a little lost when it comes to storing the values in an array or figuring out how to use the individual "tokens". mainly because i have no idea what the size of the array should be and how to easily add to the back of the array per line read in (besides perhaps having a count after every time i "add" a value to the array and add from there). Dynamic arrays do not exist in c?. atm I miss java, but I'm sure this is good for me. From fetzee01@csse.uwa.edu.au Fri Sep 4 22:00:47 2015 Date: Fri Sep 4 22:00:47 2015 Edit: Fri Sep 4 22:02:04 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: Data query From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none what's so good about Java ... I think before considering using strtok, first watch the recorded tutorial today (which addresses other queries you have in your question), Chris mentions why it may not be a good idea to use it. From graven01@csse.uwa.edu.au Fri Sep 4 22:13:13 2015 Date: Fri Sep 4 22:13:13 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Data query From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none was going to watch it this weekend. but looks like i need to watch it before i continue thanks. From newmal01@csse.uwa.edu.au Fri Sep 4 22:24:17 2015 Date: Fri Sep 4 22:24:17 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.130 Subject: Harvasines formula project 1 From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none should we use haversines formula to find the closest longitude and latitude of a stop to our strating point? From newmal01@csse.uwa.edu.au Fri Sep 4 23:20:41 2015 Date: Fri Sep 4 23:20:41 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.130 Subject: walking speed From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none are we required to design a function that calculates the time of arrival to the first pickup stop if were walking? if so is there a specific speed for which we should define a variable that represents waking speed? or should we just make it up? From jennib03@csse.uwa.edu.au Sat Sep 5 00:03:27 2015 Date: Sat Sep 5 00:03:27 2015 To: help2002@csse.uwa.edu.au Received: from 49.196.8.50 Subject: walking speed From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > are we required to design a function that calculates the time of arrival to the first > pickup stop if were walking? > > if so is there a specific speed for which we should define a variable that represents > waking speed? Quite explicitly from the project page: "Your program should allow the traveller sufficient time to walk from their starting location (typically their home) to, say, the first bus-stop. Amazingly, people can walk in straight lines at a constant speed of one metre-per-second, between any two points (through buildings!), and buses are always on time! No walking segment should be longer than 1000m." > or should we just make it up? But by all means, make stuff up! :) From 00014979@csse.uwa.edu.au Sat Sep 5 07:05:36 2015 Date: Sat Sep 5 07:05:36 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: scanf() conversition From: "Christopher McDonald" X-smilie: none X-img: none I'm unsure why you'd need it; converting a float or double with %f will correctly handle negative values. Moreover, if you embed specific knowledge/checks for negative values, then you'll be limiting your program to, say, the southern hemisphere. From 00014979@csse.uwa.edu.au Sat Sep 5 07:08:29 2015 Date: Sat Sep 5 07:08:29 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: parent station From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > are we required to use all the date from the text files? Required? No. You won't *need* all the data, and won't need all of the files. > when in the first case the parent station is 13 and in the second case there is no parent > station? As suggested in yesterday's Tutorial, why not first break the line up into comma-separated fields? It will then be easy to see if a field is empty. From 00014979@csse.uwa.edu.au Sat Sep 5 07:11:36 2015 Date: Sat Sep 5 07:11:36 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Harvasines formula project 1 From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > should we use haversines formula to find the closest longitude and latitude of a stop to > our strating point? It'll depend on the approach you're taking, but the function works, and you have the code for it, so I'm a bit confused by your question. From bradfj01@csse.uwa.edu.au Sat Sep 5 09:31:38 2015 Date: Sat Sep 5 09:31:38 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.177.248 Subject: printing to test content of file From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none Hi Just a little confused on how to print output from a File once it has been opened. I have done the while loop for fgets(), but it seems when I printf it doesn't print anything to the terminal. From graven01@csse.uwa.edu.au Sat Sep 5 09:42:31 2015 Date: Sat Sep 5 09:42:31 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: printing to test content of file From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none so its reading in a line at a time, to a character array (presumably called line) something like (from lectures) while( fgets(line, sizeof line, stops) != NULL ) //PROCESS CHARACTER ARRAY (line) HERE (line is like char line[]) From newmal01@csse.uwa.edu.au Sat Sep 5 11:29:39 2015 Date: Sat Sep 5 11:29:39 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.130 Subject: sscanf() conversion From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none while(fgets(line, sizeof line, stops)!=NULL){ if(count>=70&&count<=71){ printf("this is the full line\n"); printf("%s\n",line); char parent[5]; sscanf(line,"%d,%3[^,],%d,%d,%100[^,],%100[^,],%lf,%lf,%s",&location_type,parent,&stop_id ,&stop_code,stop_name,stop_description,&stop_lat,&stop_long,zone_id); printf("this is the location type\n"); printf("%d\n",location_type); printf("this is the stop_id\n"); printf("%d\n",stop_id); printf("this is the stop code\n"); printf("%d\n",stop_code); printf("this is the stop name\n"); printf("%s\n",stop_name); printf("this is the stop description\n"); printf("%s\n",stop_description); printf("this is the stop lat\n"); printf("%f\n",stop_lat); printf("this is the stop long\n"); printf("%f\n",stop_long); printf("this is the zone id\n"); printf("%s\n",zone_id); printf("parent is: %s\n",parent);}; is the line has a parent station all the variables are assigned correctly howeve if is does not have a parent station they are not assigned correctly? example CORRECT this is the full line 0,13,10070,10070,"Victoria Park Transfer Stn Stand E","Victoria Park Transfer Stn",-31.9682883333333020,115.888946666667,1 this is the location type 0 this is the stop_id 10070 this is the stop code 10070 this is the stop name "Victoria Park Transfer Stn Stand E" this is the stop description "Victoria Park Transfer Stn" this is the stop lat -31.968288 this is the stop long 115.888947 this is the zone id 1 parent is: 13 example INCORRECT this is the full line 0,,10071,10071,"Adelaide Tce Westend Causeway","Adelaide Tce / Westend Cway",-31.9615645625,115.8767979170,FTZ this is the location type 0 this is the stop_id 10070 this is the stop code 10070 this is the stop name "Victoria Park Transfer Stn Stand E" this is the stop description "Victoria Park Transfer Stn" this is the stop lat -31.968288 this is the stop long 115.888947 this is the zone id 1 parent is: 13 From newmal01@csse.uwa.edu.au Sat Sep 5 11:33:52 2015 Date: Sat Sep 5 11:33:52 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.130 Subject: echo From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none in the example output what does echo do? From 00014979@csse.uwa.edu.au Sat Sep 5 12:31:33 2015 Date: Sat Sep 5 12:31:33 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: sscanf() conversion From: "Christopher McDonald" X-smilie: none X-img: none Could you please not use our forum as a debugging platform, and try to keep related comments under the same topic (the same Subject line). Thank you. From 00014979@csse.uwa.edu.au Sat Sep 5 12:32:22 2015 Date: Sat Sep 5 12:32:22 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: echo From: "Christopher McDonald" X-smilie: none X-img: none What did it do when you tired it? From jennib03@csse.uwa.edu.au Sat Sep 5 13:35:52 2015 Date: Sat Sep 5 13:35:52 2015 To: help2002@csse.uwa.edu.au Received: from 49.196.8.50 Subject: echo From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none Try: prompt> echo "hello world" in your terminal and see what happens. Otherwise, what example output are you referring to? From graven01@csse.uwa.edu.au Sat Sep 5 15:16:59 2015 Date: Sat Sep 5 15:16:59 2015 Edit: Sat Sep 5 15:27:51 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: scanf From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none testing scanf. im not sure whats going wrong when the second field is empty, why isn't it just printing out an empty string (see test2) , and carrying on? obviously my understanding of the function isn't quite right. any pointers would be appreciated. (i was using strtok before but the tutorial suggested it wasn't the best method, so i was trying to mess about with this) void test(void) { char str[] = "dog,cat,bird" ; int len = strlen(str); char a[len]; char b[len]; char c[len]; sscanf(str,"%[^,],%[^,],%[^,]", a, b, c); printf("%s\n%s\n%s\n" ,a,b,c); exit(0); } Output : dog cat bird _________________________________________________________ void test2(void) { char str[] = "dog,,bird" ; int len = strlen(str); char a[len]; char b[len]; char c[len]; sscanf(str,"%[^,],%[^,],%[^,]", a, b, c); printf("%s\n%s\n%s\n" ,a,b,c); exit(0); } Output: dog ?k?[? ?? From abusha02@csse.uwa.edu.au Sat Sep 5 23:18:40 2015 Date: Sat Sep 5 23:18:40 2015 To: help2002@csse.uwa.edu.au Received: from 220.253.171.201 Subject: scanf From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none The scanf family of functions is very poorly suited for parsing comma separated values. In your case, the character [^,] that you're trying to match to won't match to an empty string, and that's why you're code isn't working. If I were you, I wouldn't waste my time trying to make scanf work; you'd be better off just writing your own code to split a csv line into fields, and then parse each field separately. Scanf is not an appropriate function for this kind of task. From fetzee01@csse.uwa.edu.au Sun Sep 6 03:49:01 2015 Date: Sun Sep 6 03:49:01 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: memset() From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none - allowed, provided we understand how to use it properly? From 00014979@csse.uwa.edu.au Sun Sep 6 05:09:52 2015 Date: Sun Sep 6 05:09:52 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: scanf From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > The scanf family of functions is very poorly suited for parsing comma separated values. In > your case, the character [^,] that you're trying to match to won't match to an empty string, > and that's why you're code isn't working. If I were you, I wouldn't waste my time trying to > make scanf work; you'd be better off just writing your own code to split a csv line into > fields, and then parse each field separately. Scanf is not an appropriate function for this > kind of task. Agreed. In the description of input conversions in online manual for scanf it says: [ Matches a nonempty sequence of characters.... A *nonempty* sequence. From 00014979@csse.uwa.edu.au Sun Sep 6 05:16:10 2015 Date: Sun Sep 6 05:16:10 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: memset() From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > - allowed, provided we understand how to use it properly? Yes, no problems; there's no restrictions on which functions you can use from the standard library (I suspect that you're only using it to fill an array with NULL-bytes?) My comment in Friday's tutorial was only about avoiding the use of strtok() - though well understood, its problems have been long and widely agreed: Why should strtok() generally be avoided? http://benpfaff.org/writings/clc/strtok.html From fetzee01@csse.uwa.edu.au Sun Sep 6 08:48:57 2015 Date: Sun Sep 6 08:48:57 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: memset() From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none >there's no restrictions on which functions you can use from the standard >library (I suspect that you're only using it to fill an array with NULL-bytes?) Thanks. Yes that is what I have been doing. From goerkl02@csse.uwa.edu.au Sun Sep 6 10:17:35 2015 Date: Sun Sep 6 10:17:35 2015 To: help2002@csse.uwa.edu.au Received: from 203.161.84.42 Subject: Project 1 partner From: "Liam Goerke" <21308002@student.uwa.edu.au> X-smilie: none X-img: none Hey, if anyone still needs a partner for project 1, send me an email at: 21308002@student.uwa.edu.au. From newmal01@csse.uwa.edu.au Sun Sep 6 20:03:13 2015 Date: Sun Sep 6 20:03:13 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.130 Subject: project 1 and dates From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none for the calender_dates.txt i am confused at to what the roll of the fiel exception type plays? From marshs11@csse.uwa.edu.au Sun Sep 6 20:04:09 2015 Date: Sun Sep 6 20:04:09 2015 To: help2002@csse.uwa.edu.au Received: from 125.253.101.232 Subject: project 1 and dates From: "Samuel Marsh" <21324325@student.uwa.edu.au> X-smilie: none X-img: none https://developers.google.com/transit/gtfs/reference?hl=en From graven01@csse.uwa.edu.au Sun Sep 6 20:55:38 2015 Date: Sun Sep 6 20:55:38 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: global variables From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none I've written a few functions so far that all require the same variables, is it better to pass the variables or pointers between the functions or just have a global variable that get altered as needed? From 00014979@csse.uwa.edu.au Mon Sep 7 09:21:33 2015 Date: Mon Sep 7 09:21:33 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: global variables From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > I've written a few functions so far that all require the same variables, is it better to > pass the variables or pointers between the functions or just have a global variable that > get altered as needed? There's no definitive answer - it's considered best practice to attempt to minimise the number of global variables, as by making accessible to every function you introduce the prospect that a function may accidentally modify one. Some programming languages don't even support global variables, while others require a function to explicitly declare that it wishes to access one, or perhaps just have read-only access to it. So it's better to pass variable s parameters, to just the functions that genuinely need them, but it's also preferred not to have an excessive number of parameters passes to functions (only for reasons of readability, no for technical reasons) - so you can't win! As a very rough rule, I'd suggest passing potentially variables as parameters, only if they're needed by 2 functions but probably make them globals if needed by more. From liaoj02@csse.uwa.edu.au Mon Sep 7 09:35:23 2015 Date: Mon Sep 7 09:35:23 2015 To: help2002@csse.uwa.edu.au Received: from 49.196.132.89 Subject: Walking distance less than 1km From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Hi. At the moment I think it is possible to get the bus stop within 1000m by iterating the calculation for the every bus stop and the starting point . However, as there are so mamy combination (said of it is in City, then will take a long time). But generally speaking is this the only approach? Thanks From liaoj02@csse.uwa.edu.au Mon Sep 7 09:45:33 2015 Date: Mon Sep 7 09:45:33 2015 Edit: Mon Sep 7 09:47:44 2015 To: help2002@csse.uwa.edu.au Received: from 49.196.132.89 Subject: Walking distance less than 1km From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Moreover, I definitely do not want to compare the distance btw a start point and all the stop but only the ones are relevant. I guess i can specify that the change in latitude and change in longtitude is at most some degree that representing 1km? From nelsoj07@csse.uwa.edu.au Mon Sep 7 09:49:31 2015 Date: Mon Sep 7 09:49:31 2015 To: help2002@csse.uwa.edu.au Received: from 121.215.157.85 Subject: Walking distance less than 1km From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none At the moment I've written the program to check the distance from the start and end coordinates and the coordinates for every stop and return those that are below 1000m, and it takes less than a second so this approach is working fine for me currently! From liaoj02@csse.uwa.edu.au Mon Sep 7 10:06:33 2015 Date: Mon Sep 7 10:06:33 2015 Edit: Mon Sep 7 10:09:31 2015 To: help2002@csse.uwa.edu.au Received: from 49.196.132.89 Subject: Walking distance less than 1km From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Did you list all possible combination? or just check the degree of lon and lat as prerequsite if more than a cerain degree then not bother calculating it From johnsd16@csse.uwa.edu.au Mon Sep 7 10:15:46 2015 Date: Mon Sep 7 10:15:46 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.91.122 Subject: Project clarifications From: "Dylan Johnson" <21469038@student.uwa.edu.au> X-smilie: none X-img: none I've got a few questions on the project: When you say one transfer at most is allowed, does this include transfers between the same type of transport, i.e. bus to bus? Are we able to submit our program in multiple linked source files? Thanks. From nelsoj07@csse.uwa.edu.au Mon Sep 7 10:49:44 2015 Date: Mon Sep 7 10:49:44 2015 To: help2002@csse.uwa.edu.au Received: from 121.215.157.85 Subject: Walking distance less than 1km From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Checked the distance for all possible combinations, if the distance is less than a 1000m then store it From liaoj02@csse.uwa.edu.au Mon Sep 7 11:10:01 2015 Date: Mon Sep 7 11:10:01 2015 To: help2002@csse.uwa.edu.au Received: from 49.196.132.89 Subject: Walking distance less than 1km From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none thanks From led05@csse.uwa.edu.au Mon Sep 7 11:10:41 2015 Date: Mon Sep 7 11:10:41 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.82.253 Subject: 2D arrays From: "Henry Le" <21317911@student.uwa.edu.au> X-smilie: none X-img: none Hey guys, If I had a 2d char array say: char temp[2][10]; and I wanted to 'put' a word into the first row or refer to the first row could i just do: temp[0] = "hello"; and call temp[0] to get the string? or would i have to get it character by character? char hello[] = temp[0]; hello == "hello"?? From jennib03@csse.uwa.edu.au Mon Sep 7 11:28:10 2015 Date: Mon Sep 7 11:28:10 2015 To: help2002@csse.uwa.edu.au Received: from 49.183.180.152 Subject: Project clarifications From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > When you say one transfer at most is allowed, does this include transfers between WALK FROM (HOME) TO FIRST STOP/STATION PUBLIC TRANSPORT LEG 1 (BUS/TRAIN/FERRY) [OPTIONAL] TRANSFER 1 (WALK) [OPTIONAL] PUBLIC TRANSPORT LEG 2 (BUS/TRAIN/FERRY) WALK TO FINAL DESTINATION That is the most complicated journey allowed (which is really about limiting scope it seems, because the algorithms get a little more complex - or at least time consuming depending on how you are solving it - from there). > the same type of transport, i.e. bus to bus? It doesn't matter what types of transport you use, you can only have two trips using any means of public transport. E.g.: walk -> bus -> walk -> train train -> walk -> train -> walk walk -> bus -> (no walking/same stop) bus -> walk > Are we able to submit our program in multiple linked source files? Project specifically says it needs to be uploaded as one file called whichbus.c (though I thought this odd as well personally!) Hope that helps (P.S. not Chris or a tutor - just going from what I've read/heard) From nelsoj07@csse.uwa.edu.au Mon Sep 7 11:52:02 2015 Date: Mon Sep 7 11:52:02 2015 To: help2002@csse.uwa.edu.au Received: from 120.145.176.167 Subject: 2D arrays From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none You can call temp[0] to return the string, but to put "hello" there anytime apart from initialisation you would need to use strcpy() ( I think, not a doctor ) From graven01@csse.uwa.edu.au Mon Sep 7 12:03:08 2015 Date: Mon Sep 7 12:03:08 2015 Edit: Mon Sep 7 12:05:16 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: 2D arrays From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none yeah i was also wondering how to place things at the back of an array like in java where you just can add. etc From chowda01@csse.uwa.edu.au Mon Sep 7 12:30:17 2015 Date: Mon Sep 7 12:30:17 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.112.22 Subject: Walking distance less than 1km From: "Anirban Chowdhury" <21432966@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > At the moment I've written the program to check the distance from the start and end > coordinates and the coordinates for every stop and return those that are below 1000m, and > it takes less than a second so this approach is working fine for me currently! Hey Jake i am trying to do the same thing as you mentioned above. However i am stuck as to how to separate out the string using commas and store the individual fields in an array so that i can find the distance between my home coordinate and those found in the strings and see if they are less than 1000m. Can you please suggest anything. Thanks in advance From graven01@csse.uwa.edu.au Mon Sep 7 12:34:28 2015 Date: Mon Sep 7 12:34:28 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Walking distance less than 1km From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > > > At the moment I've written the program to check the distance from the start and end > > coordinates and the coordinates for every stop and return those that are below 1000m, and > > it takes less than a second so this approach is working fine for me currently! > > Hey Jake i am trying to do the same thing as you mentioned above. However i am stuck as to how to > separate out the string using commas and store the individual fields in an array so that i can find > the distance between my home coordinate and those found in the strings and see if they are less than > 1000m. Can you please suggest anything. > > Thanks in advance perhaps look at looping through each character in the string and while its not a ',' put it in a individual field? you'll have to track a field index counter and add a null byte to the back of it. From liaoj02@csse.uwa.edu.au Mon Sep 7 12:35:35 2015 Date: Mon Sep 7 12:35:35 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.103.179 Subject: Walking distance less than 1km From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Moreover, how is the size of the array determined? Manually assign seems not accurate. From graven01@csse.uwa.edu.au Mon Sep 7 13:43:57 2015 Date: Mon Sep 7 13:43:57 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Walking distance less than 1km From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none "Jia Liao" <21480279@student.uwa.edu.au> wrote: > Moreover, how is the size of the array determined? Manually assign seems not accurate. count the commas? From 00014979@csse.uwa.edu.au Mon Sep 7 14:14:28 2015 Date: Mon Sep 7 14:14:28 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: 2D arrays From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > yeah i was also wondering how to place things at the back of an array like in java where you > just can add. etc If an array already has a string in it - it has a NULL-byte, then you can append another string to it using strcat(). But I'm not sure that that's what you're wanting to do - aren't you just filling in an array by modifying/incrementing the first array index (dimension) each time? From chinnd01@csse.uwa.edu.au Mon Sep 7 14:38:39 2015 Date: Mon Sep 7 14:38:39 2015 To: help2002@csse.uwa.edu.au Received: from 124.182.134.41 Subject: Project clarifications From: "David Chinnery" <21142701@student.uwa.edu.au> X-smilie: none X-img: none Benjamin is right. We asked these very questions at the tute. Only one public transport transfer and only one source file not even our own .h files :( From nelsoj07@csse.uwa.edu.au Mon Sep 7 15:12:18 2015 Date: Mon Sep 7 15:12:18 2015 To: help2002@csse.uwa.edu.au Received: from 120.145.176.167 Subject: Walking distance less than 1km From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Might not be the best way to do so, but what I did was to write a function my_strtok that I then use to get the values that I need, say the value after the 5th comma and store that if necessary. You could do a similar thing in order to separate all the fields and store them in an array or struct if wanted From newmal01@csse.uwa.edu.au Mon Sep 7 15:32:06 2015 Date: Mon Sep 7 15:32:06 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.130 Subject: program to test output From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none when will the program to test the output be released? From 00014979@csse.uwa.edu.au Mon Sep 7 15:54:56 2015 Date: Mon Sep 7 15:54:56 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Mid-semester test marks available From: "Christopher McDonald" X-smilie: none X-img: none X-announcefor: 5d The mid-semester test marks are now available via csmarks. The average was 12.9/20, std.dev 3.3 which compares well with last year's 12.4/20, 2.9 From your csmarks webpage you should also find your test's answer sheet, which you can use to check your marks against the answers. Questions: http://teaching.csse.uwa.edu.au/units/CITS2002/examinations/MSTest-2015.pdf Answers: http://teaching.csse.uwa.edu.au/units/CITS2002/examinations/test-2015-solns.pdf Analysis: http://teaching.csse.uwa.edu.au/units/CITS2002/examinations/MSTest-2015-analysis.pdf If you believe that a mistake has been made in the scanning/marking of your test, please let me know via email. From 00014979@csse.uwa.edu.au Mon Sep 7 15:56:47 2015 Date: Mon Sep 7 15:56:47 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Midsem results From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hi. When will mid-sem results be released? I thought the "advantage of multi choice > tests is that the results can be uploaded within 2 days"(Chris McDonald, 2015). There they are: https://secure.csse.uwa.edu.au/run/help2002?p=np&a=284 Uploaded within 40 minutes of me receiving them back. From lopasb03@csse.uwa.edu.au Mon Sep 7 16:00:34 2015 Date: Mon Sep 7 16:00:34 2015 Edit: Mon Sep 7 16:02:28 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.76.67 Subject: Midsem results From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Can we get the solutions, so that we can see where we went wrong, and what we need to concentrate on. Nevermind, I found them :). From fetzee01@csse.uwa.edu.au Mon Sep 7 16:11:29 2015 Date: Mon Sep 7 16:11:29 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.70.40 Subject: Midsem results From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none Hi, Is it okay if you could you post the test paper as well? From liaoj02@csse.uwa.edu.au Mon Sep 7 16:47:42 2015 Date: Mon Sep 7 16:47:42 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.103.179 Subject: Ways of filtering columns From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Hi. I am stuck at the way I use to filter columns. For example, in the stop.txt, I am interested in getting longtitude and latitude of the stop yet what function is capable of doing it? I can read all the file with getc and putchar, but filtering is still beyond me. Thanks From 00014979@csse.uwa.edu.au Mon Sep 7 16:48:36 2015 Date: Mon Sep 7 16:48:36 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Midsem results From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hi, Is it okay if you could you post the test paper as well? As (now) in the yellow announcement. From 00014979@csse.uwa.edu.au Mon Sep 7 16:49:44 2015 Date: Mon Sep 7 16:49:44 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Ways of filtering columns From: "Christopher McDonald" X-smilie: none X-img: none As mentioned in the tutorial - read the whole file in, line by line, and write a function to break the line into multiple fields, with ',' as the separator. From coopea04@csse.uwa.edu.au Mon Sep 7 18:45:17 2015 Date: Mon Sep 7 18:45:17 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.141 Subject: Variable length arrays From: "Adrian Cooper" <20786307@student.uwa.edu.au> X-smilie: angry2.png X-img: none We're trying to declare a variable-length int array in the equivalent manner as a variable length char array, but it isn't working. The code char str[]=""; works fine, and produces no warnings nor errors, but int stopsfound[] = []; int stopsfound[]; int stopsfound[] = 0; int stopsfound[] = {0}; all give errors, about tentative array definition assumed to have one element, or expected expression. Is there any easy way to declare a variable length int array like there is for char? From nelsoj07@csse.uwa.edu.au Mon Sep 7 19:04:48 2015 Date: Mon Sep 7 19:04:48 2015 To: help2002@csse.uwa.edu.au Received: from 120.145.176.167 Subject: Variable length arrays From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Instead of declaring a variable int array, why not just declare an array bigger than you think you'll need and populate it iteratively as you go? If it is for the bus stops found, Chris said in the tutorial that for any metre square in WA there were at most ~180 odd bus stops, so an array of size 200 should be big enough? Would be interested if anyone has a better answer or a proper explanation though! From liaoj02@csse.uwa.edu.au Mon Sep 7 20:00:34 2015 Date: Mon Sep 7 20:00:34 2015 To: help2002@csse.uwa.edu.au Received: from 49.196.132.229 Subject: Midsem results From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > Hi. When will mid-sem results be released? I thought the "advantage of multi choice > tests is that the results can be uploaded within 2 days"(Chris McDonald, 2015). Is it possible to have a look at my anwser sheet? As I marked the response on the question sheet but I get one mark less than what it expected to be. Moreover, for question 3,in C primer plus page 268 says option a is a semantic error, not a syntax error. for this instance, ch is compare to 'A',returing either 0 or 1. Both case is less than 'Z',so result always true. However, does isalpha return true for both lower and upper case? Then B does not gurantee a correct anwser also? From abusha02@csse.uwa.edu.au Mon Sep 7 20:31:57 2015 Date: Mon Sep 7 20:31:57 2015 To: help2002@csse.uwa.edu.au Received: from 220.253.171.201 Subject: Midsem results From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > ANONYMOUS wrote: > > > Hi. When will mid-sem results be > released? I thought the "advantage of > multi choice > > tests is that the results can be > uploaded within 2 days"(Chris McDonald, > 2015). > Is it possible to have a look at my > anwser sheet? As I marked the response on > the question sheet but I get one mark less > than what it expected to be. > Moreover, for question 3,in C primer > plus page 268 says option a is a semantic > error, not a syntax error. > for this instance, ch is compare to > 'A',returing either 0 or 1. Both case is > less than 'Z',so result always true. > However, does isalpha return true for both > lower and upper case? Then B does not > gurantee a correct anwser also? B will guarantee a correct answer as long as upper case characters appear before lower case characters in whatever character set is being used on the architecture running the code. Given that this is almost always true (I can't actually think of an exception), B is almost always going to guarantee a correct answer. You're right when you say it isn't a perfect answer, and in the hypothetical case that the program was being run on a character set where lower case characters appeared before upper case characters, B could return an incorrect answer. However, it is to my understanding that upper case always appears first, as in the past, older character sets only had upper case characters, thus newer character sets place lower case characters after upper case ones, as they're a newer addition to the character set. In short, while B isn't guaranteed to be correct on every possible character set, A is the more incorrect solution, and thus the most apppropriate answer. Don't forget that MCQ is finding the best answer; there may be more than one possible answer, but your goal is to find the most correct, and in this case that's A. From liaoj02@csse.uwa.edu.au Mon Sep 7 21:52:41 2015 Date: Mon Sep 7 21:52:41 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.126.73 Subject: Ways of filtering columns From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none If the file has 5 columns , should I creat 5 arrays to store the info column by column? Thanks From ahmedm07@csse.uwa.edu.au Mon Sep 7 22:02:15 2015 Date: Mon Sep 7 22:02:15 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.52.16 Subject: MidSem - Questions From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none Hey. So i was looking through the test. I understand why the answer for Question 10 is C. However, i was thinking that technically, shouldn't the string length remain the same considering that the array is still the same size. You could write a different method for checking String Length that doesn't rely on the NUll-byte and you would be able to see the actual length etc etc. Also. I cannot understand why Question 14 is B. Since if you consider the array to be of size 100 : 1st iteration: array[0][0] = 0; array[100 - 0 -1][0]; which would result in a 1 placed in (0,0) and (99,0) which basically missed the last column of the 2d Array. I am not sure what i am doing wrong. Thanks for helping in advance. From thatca01@csse.uwa.edu.au Mon Sep 7 23:07:03 2015 Date: Mon Sep 7 23:07:03 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.145.161 Subject: MidSem - Questions From: "Alexander Thatcher" <21498488@student.uwa.edu.au> X-smilie: none X-img: none It's the null-byte that makes a sequence of characters be considered a string, so if we ignore the null-byte we're no longer measuring the string length and rather some other value. Also, with 0-indexing (99, 0) IS the last 'column' of the array, since 99 is the 100th integer starting from 0. From liaoj02@csse.uwa.edu.au Mon Sep 7 23:47:56 2015 Date: Mon Sep 7 23:47:56 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.126.73 Subject: Ways of filtering columns From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Ideally, should we process every line then store the information in n number of arrays?(assume n columns) From 00014979@csse.uwa.edu.au Tue Sep 8 05:00:19 2015 Date: Tue Sep 8 05:00:19 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Midsem results From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Is it possible to have a look at my > anwser sheet? As I marked the response on > the question sheet but I get one mark less > than what it expected to be. Yes, you're welcome to look at your answer sheet - have you already looked at its scanned PDF via csmarks? > Moreover, for question 3,in C primer > plus page 268 says option a is a semantic > error, not a syntax error. Regardless of the type of error, option A does not correctly check for an uppercase character. The expression ('A' <= ch <= 'Z') is the same as (('A' <= ch) <= 'Z'), the first part of which evaluates to either 0 or 1, both of which are always less than 'Z' (=90). So the whole expression is always true and, thus, does not check for uppercase characters (of any character set, except maybe one in which 'Z' is less than 0) From fetzee01@csse.uwa.edu.au Tue Sep 8 05:05:40 2015 Date: Tue Sep 8 05:05:40 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: Midsem results From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > Is it possible to have a look at my > > anwser sheet? As I marked the response on > > the question sheet but I get one mark less > > than what it expected to be. > > Yes, you're welcome to look at your answer sheet - have you already looked at its scanned > PDF via csmarks? > > > Moreover, for question 3,in C primer > > plus page 268 says option a is a semantic > > error, not a syntax error. > > Regardless of the type of error, option A does not correctly check for an uppercase > character. The expression ('A' <= ch <= 'Z') is the same as (('A' <= ch) <= 'Z'), the > first part of which evaluates to either 0 or 1, both of which are always less than 'Z' > (=90). So the whole expression is always true and, thus, does not check for uppercase > characters (of any character set, except maybe one in which 'Z' is less than 0) ha, some python programmers might have accidentally gotten that question wrong (where A is a valid mathematical interpretation) From 00014979@csse.uwa.edu.au Tue Sep 8 05:10:28 2015 Date: Tue Sep 8 05:10:28 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Midsem results From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > ha, some python programmers might have accidentally gotten that question wrong (where A is a > valid mathematical interpretation) Yes, that could be the explanation, though the question wasn't designed to be a trick. I'm confused, though, why someone would ask if isalpha() returns true for both upper AND lowercase characters. From 00014979@csse.uwa.edu.au Tue Sep 8 05:17:05 2015 Date: Tue Sep 8 05:17:05 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: MidSem - Questions From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hey. > So i was looking through the test. I understand why the answer for Question 10 is C. > However, i was thinking that technically, shouldn't the string length remain the same > considering that the array is still the same size. You could write a different method > for checking String Length that doesn't rely on the NUll-byte and you would be able > to see the actual length etc etc. You're confusing the physical space occupied by the array, with its logical contents: the string. From 00014979@csse.uwa.edu.au Tue Sep 8 06:17:39 2015 Date: Tue Sep 8 06:17:39 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Variable length arrays From: "Christopher McDonald" X-smilie: none X-img: none "Adrian Cooper" <20786307@student.uwa.edu.au> wrote: > We're trying to declare a variable-length int array in the equivalent manner as a variable > length char array, but it isn't working. The code Jake's answer is the correct one, but I'm just wanting to clarify your use of terminology. C (and other languages) have things called "variable length arrays", but they have a different meaning to the one you're using. Historically, the size of arrays is C had to be known at compile-time, and so all arrays were declared with a maximum size that could be determined by the compiler: int func(void) { int a1[ 10 ]; int a2[ 2 * 4 + 1 ]; ...... In C99, the bounds of an array can now be a run-time expression. Such arrays are called variable length arrays or VLAs for short: int func(int length) { int a1[ length ]; int a2[ 2 * length ]; .... The 1st project can be completed with both constant-sized and variable-sized arrays. In next week's lecture we'll start looking at how to grow (and shrink) dynamically allocated arrays. From ahmedm07@csse.uwa.edu.au Tue Sep 8 07:27:17 2015 Date: Tue Sep 8 07:27:17 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.52.16 Subject: MidSem - Questions From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > It's the null-byte that makes a sequence of characters be considered a string, so if we > ignore the null-byte we're no longer measuring the string length and rather some other > value. > > Also, with 0-indexing (99, 0) IS the last 'column' of the array, since 99 is the 100th > integer starting from 0. Ok. And wow, i can't believe i missed that. Thankyou. From liaoj02@csse.uwa.edu.au Tue Sep 8 07:31:29 2015 Date: Tue Sep 8 07:31:29 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.124.167 Subject: Midsem results From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > ha, some python programmers might have accidentally gotten that question wrong (where A is a > > valid mathematical interpretation) > > Yes, that could be the explanation, though the question wasn't designed to be a trick. > I'm confused, though, why someone would ask if isalpha() returns true for both upper AND lowercase > characters. For example, ‘c' is alpha and less than 'Z’, the result is true, but it is not a upper letter. Shouldn't the third condition be added i.e ch>'A'? From 00014979@csse.uwa.edu.au Tue Sep 8 07:37:40 2015 Date: Tue Sep 8 07:37:40 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Midsem results From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > For example, ‘c' is alpha and less than 'Z’, the result is true, but it is not a upper letter. Shouldn't > the third condition be added i.e ch>'A'? Lowercase 'c' is not less than uppercase 'Z'. Run: man ascii From graven01@csse.uwa.edu.au Tue Sep 8 08:54:26 2015 Date: Tue Sep 8 08:54:26 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Midsem results From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none i would be interested to see the breakdown of how many people got which questions correct/incorrect as mentioned in the tutorial on friday. From 00014979@csse.uwa.edu.au Tue Sep 8 09:14:45 2015 Date: Tue Sep 8 09:14:45 2015 Edit: Tue Sep 8 09:18:25 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Midsem results From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > i would be interested to see the breakdown of how many people got which questions correct/incorrect as mentioned in the > tutorial on friday. Go wild! http://teaching.csse.uwa.edu.au/units/CITS2002/examinations/MSTest-2015-analysis.pdf I'd like to suggest too many Easy questions, but the average of 12.9/20 tells me that it was 'about right'. From graven01@csse.uwa.edu.au Tue Sep 8 09:31:49 2015 Date: Tue Sep 8 09:31:49 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Tips for vim users From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none just learning how to use vim effiecently at the moment, thought id share some helpful tips that i have found useful so far. re-map you caps lock key to escape. https://pqrs.org/osx/karabiner/seil.html.en This saves a bunch of time if you are going to be switching modes a lot. increase key repeat. https://pqrs.org/osx/karabiner/ makes a huge difference in scrolling around. 400 delay until repeat / 20 key repeat works well for me, but play around. learn the most useful shortcuts keys. http://www.viemu.com/vi-vim-cheat-sheet.gif don't touch your mouse. any one else have some good ones? From newmal01@csse.uwa.edu.au Tue Sep 8 12:59:08 2015 Date: Tue Sep 8 12:59:08 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.135 Subject: Echo leavehome From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none if the output im not quite sure how to set the envirmonetal variable LEAVEHOME from the terminal into the program could anyone help? From newmal01@csse.uwa.edu.au Tue Sep 8 13:23:39 2015 Date: Tue Sep 8 13:23:39 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.135 Subject: LEAVEHOME From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none how do i print out enviromental variabls? From 00014979@csse.uwa.edu.au Tue Sep 8 13:57:22 2015 Date: Tue Sep 8 13:57:22 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Echo leavehome From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > if the output im not quite sure how to set the envirmonetal variable LEAVEHOME from the > terminal into the program could anyone help? As on the project description, the command: export LEAVEHOME="`date '+%a %H:%M'`" will set it to the current day/time, or you can just "make it up", by providing your own fixed values: export LEAVEHOME="Tue 14:10" From 00014979@csse.uwa.edu.au Tue Sep 8 13:58:57 2015 Date: Tue Sep 8 13:58:57 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: LEAVEHOME From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > how do i print out enviromental variabls? From the shell prompt: echo $LEAVEHOME or if asking about from with a C program, first find the variable, by name, by calling t6he standard function getenv() From 00014979@csse.uwa.edu.au Tue Sep 8 14:26:09 2015 Date: Tue Sep 8 14:26:09 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Project modifications From: "Christopher McDonald" X-smilie: none X-img: none X-announcefor: 4d Please read: http://teaching.csse.uwa.edu.au/units/CITS2002/projects/project1-clarifications.php and http://teaching.csse.uwa.edu.au/units/CITS2002/projects/project1.php As ever, please ask for any further clarifications. From goerkl02@csse.uwa.edu.au Tue Sep 8 14:56:11 2015 Date: Tue Sep 8 14:56:11 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.179.203 Subject: Project 1 partner From: "Liam Goerke" <21308002@student.uwa.edu.au> X-smilie: none X-img: none Update, I now have a Partner . From kahwan01@csse.uwa.edu.au Tue Sep 8 15:01:03 2015 Date: Tue Sep 8 15:01:03 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.141.15 Subject: Project modifications From: "Nerces Kahwajian" <21592645@student.uwa.edu.au> X-smilie: none X-img: none Hi Chris, Now that we are assuming all buses run on all days. Which timetable should we use? As Monday - Friday, Saturday and Sunday all have different schedules. Thanks! From 00014979@csse.uwa.edu.au Tue Sep 8 16:31:53 2015 Date: Tue Sep 8 16:31:53 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Project modifications From: "Christopher McDonald" X-smilie: none X-img: none "Nerces Kahwajian" <21592645@student.uwa.edu.au> wrote: > Hi Chris, > > Now that we are assuming all buses run on all days. Which timetable should we use? As > Monday - Friday, Saturday and Sunday all have different schedules. I think it (was) more complicated than that - though correct me if I'm wrong. Using the service_id field from calendar.txt, there's 23 different timetable patterns: cut -d, -f2-8 calendar.txt | sort -u Service 81, for example, only runs Mon, Tue, Wed: grep '^81' calendar.txt With the project modifications I was hoping that we could just overlap/make a union of all timetables as if all services run every day, and not have to check calendar.txt ?? From fetzee01@csse.uwa.edu.au Tue Sep 8 17:54:59 2015 Date: Tue Sep 8 17:54:59 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: Project modifications From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none so you are saying that calendar.txt is no longer of importance to the task? From liaoj02@csse.uwa.edu.au Tue Sep 8 17:56:52 2015 Date: Tue Sep 8 17:56:52 2015 To: help2002@csse.uwa.edu.au Received: from 49.196.132.229 Subject: writing new txt or store in memory? From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Hi. Should we store the useful info in one txt then extract the useful argument needed? From nelsoj07@csse.uwa.edu.au Tue Sep 8 18:05:12 2015 Date: Tue Sep 8 18:05:12 2015 To: help2002@csse.uwa.edu.au Received: from 121.221.30.6 Subject: writing new txt or store in memory? From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none I can only see speed decreases from that approach on a modern computer with more than enough memory available for this type of program, so personally I'd keep it in memory rather than re-write it and re-read it each time needed! From liaoj02@csse.uwa.edu.au Tue Sep 8 18:14:13 2015 Date: Tue Sep 8 18:14:13 2015 To: help2002@csse.uwa.edu.au Received: from 49.196.132.229 Subject: writing new txt or store in memory? From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none I think i.need.to read all the relavant info at once then all store in arrays?Then when i try to match stop id in stop.txt and the one in route or whatever has service time related to it I can easily acceess those memories? From ahmedm07@csse.uwa.edu.au Tue Sep 8 19:40:05 2015 Date: Tue Sep 8 19:40:05 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.52.16 Subject: Only Walking? From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none Hey, Just a small question regarding the test. If its possible to walk to the destination, so the destination is under 1000m, then should that just be our answer or do we need to find a way to use bus, train or ferry? Thanks. From jennib03@csse.uwa.edu.au Tue Sep 8 19:47:24 2015 Date: Tue Sep 8 19:47:24 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.225.60 Subject: Only Walking? From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none I can't say for certain, but I would assume it fits within the specs of the project. If it is the fastest route, then display that. From jennib03@csse.uwa.edu.au Tue Sep 8 20:06:58 2015 Date: Tue Sep 8 20:06:58 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.225.60 Subject: Project modifications From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > With the project modifications I was hoping that we could just overlap/make a union of all > timetables as if all services run every day, and not have to check calendar.txt I'm wondering if it would be easier to actual code to account for what day the trips are running on than to work out the new rules about "assume trips run on all days." Some days/times have variations as well... such as 344D or similar. From lis63@csse.uwa.edu.au Tue Sep 8 20:18:45 2015 Date: Tue Sep 8 20:18:45 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.185.96 Subject: Variable length arrays From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none I ues malloc(), realloc() and free(). I think it's the most economic way to achieve variable length arrays, though it's dangerous if forget to free the array. From lis63@csse.uwa.edu.au Tue Sep 8 21:32:34 2015 Date: Tue Sep 8 21:32:34 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.221.171 Subject: Project modifications From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none Thank you! So we need to write a function to make a union of all timetables in our project code? I'm not sure if I understand it as it seems a little strange. For example, If we have route 99 at 3:00pm on Monday and route 99 at 3:01 pm on Sunday, we'll have route 99 at 3:00pm and 3:01pm everyday. On extreme conditions, one stop may have ten buses of same route in ten minutes. From nelsoj07@csse.uwa.edu.au Tue Sep 8 21:42:52 2015 Date: Tue Sep 8 21:42:52 2015 To: help2002@csse.uwa.edu.au Received: from 121.221.30.6 Subject: Project 1 Testing and Validation From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: insane.png X-img: none Hey everyone, I've got my program to print out a shortest time, but I'm not sure that it's doing so correctly. There are small hints that it's not. Does anyone have any proven trips that I could use to validate my output? Or any ideas on how to do so easily? From liaoj02@csse.uwa.edu.au Tue Sep 8 21:49:49 2015 Date: Tue Sep 8 21:49:49 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.124.167 Subject: Project 1 Testing and Validation From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none so quick..mind helping us sometime? hha From liaoj02@csse.uwa.edu.au Tue Sep 8 21:51:29 2015 Date: Tue Sep 8 21:51:29 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.124.167 Subject: Only Walking? From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none "Maktoom Ahmed" <21728592@student.uwa.edu.au> wrote: > Hey, > Just a small question regarding the test. > If its possible to walk to the destination, so the destination is under 1000m, then > should that just be our answer or do we need to find a way to use bus, train or ferry? > Thanks. WIll there be any case that there is no bus stop within 1000 m? From nelsoj07@csse.uwa.edu.au Tue Sep 8 21:52:59 2015 Date: Tue Sep 8 21:52:59 2015 To: help2002@csse.uwa.edu.au Received: from 121.221.30.6 Subject: Project 1 Testing and Validation From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none What are you having issues with? If you've got any specific problems and I can help I'll try to! From liaoj02@csse.uwa.edu.au Tue Sep 8 21:54:39 2015 Date: Tue Sep 8 21:54:39 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.124.167 Subject: First argument "transperth" From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Hi. Just wondering what is the first argument "transperth" mean in sample execution? From nelsoj07@csse.uwa.edu.au Tue Sep 8 21:57:57 2015 Date: Tue Sep 8 21:57:57 2015 To: help2002@csse.uwa.edu.au Received: from 121.221.30.6 Subject: First argument "transperth" From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none The first argument is the name of the folder containing the text files needed to run, given from Transperths GTFS data. Does that make sense? :) From liaoj02@csse.uwa.edu.au Tue Sep 8 22:03:13 2015 Date: Tue Sep 8 22:03:13 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.124.167 Subject: Project 1 Testing and Validation From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Basically is the reading of data. At the moment I use "," as delimiters, for example location_type, parent_station, stop_id, stop_code, stop_name, stop_desc, stop_lat, stop_lon, zone_id 0,,10000,10000,"Albany Hwy After Armadale Rd","",-32.1479054960,116.0201957650,4 If I want the long and lat,I would say int count =0 ; //count the number of comma for one line, read that line until reaches its end if encounter a common, count ++ Start reading if count >=6 && count < 7 && count >=7 && count < 8 I will get : -32.1479054960,116.0201957650 but how would I store such information? Do I initialize say char * long[10000] then populate the coordinate in ? (They are string not double right?) Overall, its my approach correct? From liaoj02@csse.uwa.edu.au Tue Sep 8 22:08:55 2015 Date: Tue Sep 8 22:08:55 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.124.167 Subject: First argument "transperth" From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Thank you. From liaoj02@csse.uwa.edu.au Tue Sep 8 22:09:29 2015 Date: Tue Sep 8 22:09:29 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.124.167 Subject: Best route means? From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Least time or least distance?Or given a arrival time, the earliest? From nelsoj07@csse.uwa.edu.au Tue Sep 8 22:11:00 2015 Date: Tue Sep 8 22:11:00 2015 To: help2002@csse.uwa.edu.au Received: from 121.221.30.6 Subject: Project 1 Testing and Validation From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > Basically is the reading of data. > At the moment I use "," as delimiters, > > for example > location_type, parent_station, stop_id, stop_code, stop_name, stop_desc, stop_lat, stop_lon, > zone_id > 0,,10000,10000,"Albany Hwy After Armadale Rd","",-32.1479054960,116.0201957650,4 > If I want the long and lat,I would say > int count =0 ; //count the number of comma > > for one line, read that line until reaches its end > if encounter a common, count ++ > > Start reading if count >=6 && count < 7 && count >=7 && count < 8 > > I will get : > -32.1479054960,116.0201957650 > > but how would I store such information? > Do I initialize say char * long[10000] then populate the coordinate in ? (They are string not > double right?) > > Overall, its my approach correct? It looks like you're on the right track! Personally I read from that line until I get to the next comma, so I get each field separately and then convert from string to float and use it then. I'd advise writing your own version of strtok() that accepts a string and an int as a parameter, then returns the field in that position, e.g. char line[1000] = "0,,10000,10000,""Albany Hwy After Armadale Rd"","",-32.1479054960,116.0201957650,4"; new_strtok(line,6) = -32.1479054960 Does that make sense? From nelsoj07@csse.uwa.edu.au Tue Sep 8 22:13:16 2015 Date: Tue Sep 8 22:13:16 2015 To: help2002@csse.uwa.edu.au Received: from 121.221.30.6 Subject: Best route means? From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Least total time from start to end of journey, in the project description: The definition of the "best" route is the one requiring the minimum total journey time, consisting of single-segment: from: http://teaching.csse.uwa.edu.au/units/CITS2002/projects/project1.php From liaoj02@csse.uwa.edu.au Tue Sep 8 22:22:46 2015 Date: Tue Sep 8 22:22:46 2015 Edit: Tue Sep 8 22:34:26 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.124.167 Subject: Project 1 Testing and Validation From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Cheers. I see, you call it once every time you read one line and record the information you are interested. And mystrok() need to account for different type of data type ? Said lat and lon is double, address is string ,stop number is int ect. From nelsoj07@csse.uwa.edu.au Tue Sep 8 22:29:15 2015 Date: Tue Sep 8 22:29:15 2015 To: help2002@csse.uwa.edu.au Received: from 121.221.30.6 Subject: Project 1 Testing and Validation From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none No I need to call my version of strtok() any time I need a field from a text string, so once per line! Also incase it was an accident, the anonymous tag came off when you edited your comment last, but you should be able to edit it again to change it back :) From liaoj02@csse.uwa.edu.au Tue Sep 8 22:35:05 2015 Date: Tue Sep 8 22:35:05 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.124.167 Subject: Project 1 Testing and Validation From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Cheers. I see, you call it once every time you read one line and record the information you are interested. And mystrok() need to account for different type of data type ? Said lat and lon is double, address is string ,stop number is int ect. Hhaha you know who am I From newmal01@csse.uwa.edu.au Tue Sep 8 22:38:56 2015 Date: Tue Sep 8 22:38:56 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.135 Subject: Trip_id From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none is it correct to say that if the initial stop and the final stop have the same trip_id then if you catch the transport at the initial stop_id you can get off at the final_stop_id without having to transfer? From nelsoj07@csse.uwa.edu.au Tue Sep 8 22:39:11 2015 Date: Tue Sep 8 22:39:11 2015 To: help2002@csse.uwa.edu.au Received: from 121.221.30.6 Subject: Project 1 Testing and Validation From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none The way that I wrote my function it checks character by character between the commas and returns a string, so you then need to use / find / write a function to convert a strong to another format if needed, like int or double! From jennib03@csse.uwa.edu.au Tue Sep 8 22:41:15 2015 Date: Tue Sep 8 22:41:15 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.225.60 Subject: Project modifications From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > On extreme conditions, one stop may have ten buses of same route in ten minutes. That is my concern as well! Wouldn't it be easier to just check routes on a particular day, than try and combine all routes? :/ From jennib03@csse.uwa.edu.au Tue Sep 8 22:42:56 2015 Date: Tue Sep 8 22:42:56 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.225.60 Subject: Only Walking? From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none "Jia Liao" <21480279@student.uwa.edu.au> wrote: > WIll there be any case that there is no bus stop within 1000 m? Sure, I want to go to the shops down the road. There is normally a bus that happens to go down my street when I am lazy, but it's late and the buses have given up for the night. There's a hypothetical... From liaoj02@csse.uwa.edu.au Tue Sep 8 22:54:20 2015 Date: Tue Sep 8 22:54:20 2015 Edit: Tue Sep 8 22:55:18 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.124.167 Subject: Project 1 Testing and Validation From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Ye. I also got a conceptual question, how do those extracted data communicate with each other? Say stop id in stops.txt has somethings to do with stop_time.txt (a certain trip has a stop at certain stops at certain time , the join is stop_id). What would be the way to connect them though.. From newmal01@csse.uwa.edu.au Tue Sep 8 22:55:05 2015 Date: Tue Sep 8 22:55:05 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.135 Subject: 2d array of characters From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none if there anyway i can create a array of strings unising a 2d array for example if i declare the array char words[200][200]; is it possible to assign a string for each row by doing the following? words[1][200]="a bunch o rando leddars" if not is there a way to do this? From 00014979@csse.uwa.edu.au Wed Sep 9 04:22:53 2015 Date: Wed Sep 9 04:22:53 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Trip_id From: "Christopher McDonald" X-smilie: none X-img: none Yes; a trip_id corresponds to one physical bus. From 00014979@csse.uwa.edu.au Wed Sep 9 04:27:39 2015 Date: Wed Sep 9 04:27:39 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: 2d array of characters From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > if there anyway i can create a array of strings unising a 2d array > for example if i declare the array > char words[200][200]; > > is it possible to assign a string for each row by doing the following? > > words[1][200]="a bunch o rando leddars" > > if not is there a way to do this? With the assignment, above, you're trying to assign/store a whole string into a single character. Won't fit. You could use: strcpy(words[1], "a bunch o rando leddars"); From 00014979@csse.uwa.edu.au Wed Sep 9 04:40:12 2015 Date: Wed Sep 9 04:40:12 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Variable length arrays From: "Christopher McDonald" X-smilie: none X-img: none "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > I ues malloc(), realloc() and free(). I think it's the most economic way to achieve variable > length arrays, though it's dangerous if forget to free the array. Agreed, but using those functions is not using 'variable length arrays', but using 'dynamic memory allocation' and then treating that dynamically allocated memory as an array. While they can achieve the same purpose, it's important to use the correct terminology, else we may confuse what's going on - for example, you cannot extend a VLA using realloc(). From liaoj02@csse.uwa.edu.au Wed Sep 9 08:22:44 2015 Date: Wed Sep 9 08:22:44 2015 Edit: Wed Sep 9 08:33:53 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.127.70 Subject: Project 1 Testing and Validation From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Hi Jake. I have got a prototype like this: int mystrtok(char line[],int n) { int length = sizeof(line); char ch; int count=0; for(int j =0 ; j< length ; j++) { ch = getchar(); if(ch != NULL) { if(ch ==',') { count = count+1; // count the number of comma } else if (count == n && count < n+1) { printf("%c",ch); } } } printf("\n"); } int main() { char line[] ="a,b,c"; mystrtok(line,1); } When I run it, it doesn't print anything. What could be wrong? Thanks From nelsoj07@csse.uwa.edu.au Wed Sep 9 08:36:55 2015 Date: Wed Sep 9 08:36:55 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.12.68 Subject: Project 1 Testing and Validation From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none I'm on my phone, but does your getchar actually get anything? Will have a look more in ten when I'm at uni! From liaoj02@csse.uwa.edu.au Wed Sep 9 09:26:56 2015 Date: Wed Sep 9 09:26:56 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.127.70 Subject: Project 1 Testing and Validation From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none I know why, is because getchar() gets input from keyboard rather than file.. From liaoj02@csse.uwa.edu.au Wed Sep 9 09:37:46 2015 Date: Wed Sep 9 09:37:46 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.127.70 Subject: Project 1 Testing and Validation From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none if mystrok() take in a string array and integer as parameter, then what should i put in as have the file pointer *fp? I think the function can read is fgets and gets, both require file pointer though..I will try array pointer. From nelsoj07@csse.uwa.edu.au Wed Sep 9 09:40:33 2015 Date: Wed Sep 9 09:40:33 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.235.222 Subject: Project 1 Testing and Validation From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none These are the errors I'm getting when compiling at the moment: anonstrtok.c:6:23: error: sizeof on array function parameter will return size of 'char *' instead of 'char []' [-Werror,-Wsizeof-array-argument] int length = sizeof(line); ^ anonstrtok.c:4:19: note: declared here int mystrtok(char line[],int n) ^ anonstrtok.c:12:15: error: comparison between pointer and integer ('int' and 'void *') [- Werror] if(ch != NULL) ~~ ^ ~~~~ anonstrtok.c:32:9: error: control reaches end of non-void function [-Werror,-Wreturn-type] } ^ From ahmedm07@csse.uwa.edu.au Wed Sep 9 09:57:38 2015 Date: Wed Sep 9 09:57:38 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.52.16 Subject: Question Regarding Route From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none I was just thinking about travelling and the whole single segment modification. I am not sure if i am not understanding right but the gist is that. The person will first walk to the stop, get on a train, or bus or ferry ( only one ) and then get off on the stop and then walk to the destination. Wouldn't there be many different cases where this is simply not possible? Maybe the bus doesn't drop them within a 1000m of the destination, or maybe that the train only gets them to Esplanade Station but travelling to UWA would be walking and that's more than 1000m, i believe. Really would love it if someone could just clear this up. Thanks From nelsoj07@csse.uwa.edu.au Wed Sep 9 10:03:51 2015 Date: Wed Sep 9 10:03:51 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.235.222 Subject: Question Regarding Route From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Yes of course, which means that your program would need to say something to the effect of that. For instance it might print: No single journey routes available between point 1 and point 2 in the next hour. Does that make sense? :) From lis63@csse.uwa.edu.au Wed Sep 9 11:31:18 2015 Date: Wed Sep 9 11:31:18 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.185.96 Subject: Variable length arrays From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none Thank you! I see. I misunderstood the terminology VAL From newmal01@csse.uwa.edu.au Wed Sep 9 22:20:09 2015 Date: Wed Sep 9 22:20:09 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.135 Subject: While loop and segmentation fault From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none i am trying to run the following code #include #include #include #include #include #include #include #define STOPTIMES "/Users/21107195/Desktop/google_transit/stop_times.txt" #define STOPS "/Users/21107195/Desktop/google_transit/stops.txt" #define EARTH_RADIUS_IN_METRES 6372797 //FUNCTION WHICH CONVERST DEGREES TO RADIANS double degrees_to_radians(double degrees); //FUNCTION TO DETERMINE WHETHER LATITUDES AND LONGITUDES ARE VALID bool valid_location(double lattitude,double longitude); //FUNCTION WHICH RETURN THE DISTANCE BETWEEN 2 POINTS ON A SPHERE double haversine(double lat1, double lon1, double lat2, double lon2); double getlat(int stop_id); //FUNCTION WHICH RETURNS LONGITUDE OF STOP ID double getlong(int stop_id); int main(void){ int trip_id; int hour; int minute; int stop_id; double stop_lat; double stop_long; FILE *stoptimes; //OPEN FILE stops.txt stoptimes=fopen(STOPTIMES, "r"); if(stoptimes==NULL){ printf("cannot open file stoptimes\n"); exit(EXIT_FAILURE); } //CREATE ARRAY TO STORE LINE OF stops.txt char line[BUFSIZ]; //CONDITIONAL VARIABLE FOR WHILE LOOP int count=0; while(fgets(line, sizeof line, stoptimes)!=NULL){ printf("count =%d and line is:\n",count); printf("%s\n",line); printf("\n"); if(count>0){ sscanf(line,"%d,%d:%d:%*d,%*d:%*d:%*d,%d,%*d,%*d,%*d,%*d",&trip_id,&hour,&minute,&stop_id ); //GET LATTITUDE OF STOP ID stop_lat=getlat(stop_id); printf("stop lat=%lf\n",stop_lat); //GET LONGITUDE OF STOP ID stop_long=getlong(stop_id); } count++; } however for some reason the loop runs only 127 times and then returns segmentation fault 11 From 00014979@csse.uwa.edu.au Thu Sep 10 04:42:34 2015 Date: Thu Sep 10 04:42:34 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: While loop and segmentation fault From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > i am trying to run the following code > ............ > > however for some reason the loop runs only 127 times and then returns segmentation fault > 11 There's nothing glaringly wrong with the code you've provided, and if I provide my own functions: double getlat(int stop_id) { return 0.0; } double getlong(int stop_id) { return 0.0; } it runs to completion without error. [and we're still not a debugging forum] From liaoj02@csse.uwa.edu.au Thu Sep 10 13:51:05 2015 Date: Thu Sep 10 13:51:05 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.103.179 Subject: 2d array of characters From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Do we need to use 2d array to store the info(said stop_id)? Or a 1-d array with enough size can do it? I have some conceputal confusion which is does how do fget knows which line it is reading so that the index of that line can be stored? Otherwise without index we cannot locate the stop_id ? Thanks From leongd02@csse.uwa.edu.au Thu Sep 10 15:05:23 2015 Date: Thu Sep 10 15:05:23 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.245.157 Subject: 2d array of characters From: "Dylan Leong" <21485566@student.uwa.edu.au> X-smilie: none X-img: none uhh character arrays only hold one char in each 'slot' so if you tried to store stop ids 10000, 20000, and 30000 in a 1d array you'd pretty much have: [1][0][0][0][0][2][0][0][0][0][3][0][0][0][0] not sure if you wanna deal with that... From nelsoj07@csse.uwa.edu.au Thu Sep 10 15:09:48 2015 Date: Thu Sep 10 15:09:48 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.235.222 Subject: 2d array of characters From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none You could use an array of ints, but pretty much all those decisions are up to you! I might be wrong, but I don't think fget stores the "index of the line" as such. You could look into creating an array which also stored the respective line count, or you could store the information you need in a new struct, or any number of approaches. From liaoj02@csse.uwa.edu.au Thu Sep 10 15:13:02 2015 Date: Thu Sep 10 15:13:02 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.182 Subject: Project 1 Testing and Validation From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Hi Jake. Do you reckon a 2d array will do better than 1D in terms of storage? E.g. If I initialise a 1D array result[1000] which use to store the filed value and add a null byte at the end of the element, it will be full when the number of character reach 1000. If I use 2D [1000][6], it can store 1000 ID rather than 1000 characters.Moreover, I can index the line as well. In 1D I cannot. Thanks From liaoj02@csse.uwa.edu.au Thu Sep 10 15:14:54 2015 Date: Thu Sep 10 15:14:54 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.182 Subject: 2d array of characters From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none 2D will be better such as stopid[10000][6] From liaoj02@csse.uwa.edu.au Thu Sep 10 17:36:12 2015 Date: Thu Sep 10 17:36:12 2015 To: help2002@csse.uwa.edu.au Received: from 49.196.132.31 Subject: Which condition come first? From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none When I am optimizing the bus stop within 1000m, should I consider tripid first then bus stop time(whichever comes first get on that)? From nelsoj07@csse.uwa.edu.au Thu Sep 10 17:40:55 2015 Date: Thu Sep 10 17:40:55 2015 To: help2002@csse.uwa.edu.au Received: from 175.45.145.42 Subject: Which condition come first? From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none If I understand your question right, then you mean to get on the first bus that comes past? That might not be the shortest route though, so it depends on the structure of the rest of your program. IF I've understood that wrong let me know :) From liaoj02@csse.uwa.edu.au Thu Sep 10 17:45:32 2015 Date: Thu Sep 10 17:45:32 2015 To: help2002@csse.uwa.edu.au Received: from 49.196.132.31 Subject: Which condition come first? From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Ideally Only get on the bus that can bring me to the destination or at least close.to it then consider which one comes first given maybe 2 buese bpth can do it From ahmedm07@csse.uwa.edu.au Thu Sep 10 18:41:00 2015 Date: Thu Sep 10 18:41:00 2015 Edit: Thu Sep 10 18:46:16 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.52.16 Subject: Which condition come first? From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > Ideally Only get on the bus that can bring > me to the destination or at least close.to > it then consider which one comes first > given maybe 2 buese bpth can do it I was thinking maybe using this process: 1) Find the list of bus-stops within a 1000m of the starting position. 2) Find the list of bus-stops within a 1000m of the destination. 3) Find out if there is are buses that run within the corresponding bus-stops.Find which bus would result in the smallest amount of time travelling. 4) Figure out if there is a bus coming in the next hour. I am not sure if this is right so would love it if someone can point out if there is a glaring fault in my procedure. From lopasb03@csse.uwa.edu.au Thu Sep 10 19:46:45 2015 Date: Thu Sep 10 19:46:45 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.75.173 Subject: Using the arguments from main in a function From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: beret.png X-img: none I am trying to use the beginning latitudes and longitudes which are argv[2] and argv[3] respectively in the haversine function. I have the following: void stops(void){ for (int i = 0; i <= lines ; i++) { //applying the haversine formula using the appropriate arguments. if( (haversine(blatitudes, blongitudes, lat[i], lon[i])) <= 1000.0) { printf("stop[%d] = %d",i,stop[i]); } } However, I do not know how to reference the beginning latitude and longitude (blatitudes and blongitudes) from argv[2] and argv[3], which are input into the command line. Do I use a pointer or something, does anyone know? From graven01@csse.uwa.edu.au Thu Sep 10 20:24:43 2015 Date: Thu Sep 10 20:24:43 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Passing strings From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none So without using the forum to debug my code when i pass a line to my line function that process a line at a time looking for certain things to store it, it makes NO modifications on the line but for some reason changes it to an empty string, i can get around it by passing it a strcopy of the line but isn't this wasteful and a bad practice? i'm not sure i fully understand whats going on. From nelsoj07@csse.uwa.edu.au Thu Sep 10 20:40:30 2015 Date: Thu Sep 10 20:40:30 2015 To: help2002@csse.uwa.edu.au Received: from 124.178.148.143 Subject: Passing strings From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none I'm not really sure what's going on specifically, but maybe go through and make one hundred per cent sure that you're not unintentionally editing the line at all, just passing it as an argument like: void function (char string[]) From nelsoj07@csse.uwa.edu.au Thu Sep 10 20:43:16 2015 Date: Thu Sep 10 20:43:16 2015 To: help2002@csse.uwa.edu.au Received: from 124.178.148.143 Subject: Using the arguments from main in a function From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none One way to do so would be to declare a variable and set it to the arguments needed. An example with integers, needing argv[1], would be: int variable = atoi( argv[1] ); In this example atoi() is a function converting the argument to an integer. Does that help clear it up? :) From nelsoj07@csse.uwa.edu.au Thu Sep 10 20:53:54 2015 Date: Thu Sep 10 20:53:54 2015 To: help2002@csse.uwa.edu.au Received: from 124.178.148.143 Subject: Project 1 Testing and Validation From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none That's true, but I don't quite get how you'd implement an index effectively? For instance a 2D array or a 1D array of stop IDs, if you stored lets say five results like so: (2D array) INDEX | STOP ID | 1 123 2 456 3 789 4 111 5 222 (1D array) STOP ID 123 456 789 111 222 How do you get stop ID 111? You still need to search through and find it, unless implementing more of a database in C, which would be a whole other problem! The choice of 1D or 2D array or even a struct really seems to be preference based on how your program is planned out :) From graven01@csse.uwa.edu.au Thu Sep 10 21:05:33 2015 Date: Thu Sep 10 21:05:33 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Passing strings From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none for some reason it seems to be modifying the line , i tested it with a test function like you suggested nad that just printed out the line and it was complete in all three states before during and after the function pass. so i'm not sure whats going on in the function that appears to be changing it i have (something like) for (int i= 0; i< length; i++) while ( line_in[i] != ',') field[index] = line_in[i]; this surely cant be modifying the string right ? its just copying certain characters over? From nelsoj07@csse.uwa.edu.au Thu Sep 10 21:12:36 2015 Date: Thu Sep 10 21:12:36 2015 To: help2002@csse.uwa.edu.au Received: from 124.178.148.143 Subject: Passing strings From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none From that snippet I don't see how it could change the line. IS it perhaps that the function is not returning the field in a usable way? Or that you're not storing the function result in a variable? From lopasb03@csse.uwa.edu.au Thu Sep 10 22:05:14 2015 Date: Thu Sep 10 22:05:14 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.75.173 Subject: Using the arguments from main in a function From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none I think your missing the point of what I am trying to do. I want to use the command line arguments in my function. I just don't know if there is a way to do this or how to reference them? From ahmedm07@csse.uwa.edu.au Thu Sep 10 22:09:26 2015 Date: Thu Sep 10 22:09:26 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.52.16 Subject: Preicsion while using Floating Point From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none Alright. So i have a array with the latitude inside it. I used atof(array) to convert to a float but i am not sure why but i am losing precision. So for example: if my array contains -32.1479054960 then the float i get returned is only -32.147905. Why is that happening? Let me know. From ahmedm07@csse.uwa.edu.au Thu Sep 10 22:23:04 2015 Date: Thu Sep 10 22:23:04 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.52.16 Subject: Preicsion while using Floating Point From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none No Worries. My Mistake. :) Just to contribute info, there wasn't any precision loss but the printf function does rounding automatically. :) From jennib03@csse.uwa.edu.au Thu Sep 10 22:37:50 2015 Date: Thu Sep 10 22:37:50 2015 Edit: Thu Sep 10 22:42:15 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.225.60 Subject: Using the arguments from main in a function From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > I am trying to use the beginning latitudes and longitudes which > are argv[2] and argv[3] respectively in the haversine function. > I have the following: You need to pass the arguments from main to your stops function. I've modified the function slightly, and the usage would be: > void stops(blat, blon){ > for (int i = 0; i <= lines ; i++) > { > // ... Now you can use blat (argv[2]) and blon (argv[3]) as your vars here if that's what you need. > } > } int main(int argc, char *argv[]) { // You'll possibly need to check the input and convert it here as Jake said. // For example: double lat1 = atof( argv[2] ); // Note it's atof, as a coord is a decimal. double lon1 = atof( argv[3] ); stops(lat1, lon2); } From soarec01@csse.uwa.edu.au Thu Sep 10 22:41:47 2015 Date: Thu Sep 10 22:41:47 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.163.49 Subject: Opening the transit folder From: "Christopher Soares" <21329621@student.uwa.edu.au> X-smilie: none X-img: none When we write the code to open the necessary files, can we assume that the directory whose name we pass to the function is inside the home directory, not inside any other sub-directories? From jennib03@csse.uwa.edu.au Thu Sep 10 22:50:11 2015 Date: Thu Sep 10 22:50:11 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.225.60 Subject: Preicsion while using Floating Point From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none The other possibility (though probably unlikely) fwiw is that you are using float. There is no guarantee how precise a float will be - if you need more precision, you could use a double. From ahmedm07@csse.uwa.edu.au Thu Sep 10 22:57:55 2015 Date: Thu Sep 10 22:57:55 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.52.16 Subject: Preicsion while using Floating Point From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none Also a very fair point, i changed to double when i realized it. Thanks for the tip. :) From 00014979@csse.uwa.edu.au Fri Sep 11 04:18:05 2015 Date: Fri Sep 11 04:18:05 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Opening the transit folder From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > When we write the code to open the necessary files, can we assume that the directory > whose name we pass to the function is inside the home directory, not inside any other > sub-directories? No; don't (and there's no need) to make that assumption. It could be anywhere. From 00014979@csse.uwa.edu.au Fri Sep 11 04:19:29 2015 Date: Fri Sep 11 04:19:29 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Using the arguments from main in a function From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > However, I do not know how to reference the beginning latitude and > longitude (blatitudes and blongitudes) from argv[2] and argv[3], which > are input into the command line. Do I use a pointer or something, does > anyone know? What does the code developed in Tutorial-3 do? From 00014979@csse.uwa.edu.au Fri Sep 11 04:20:52 2015 Date: Fri Sep 11 04:20:52 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Passing strings From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > so i'm not sure whats going on > in the function that appears to be changing it i have (something like) > > for (int i= 0; i< length; i++) > while ( line_in[i] != ',') > field[index] = line_in[i]; > > this surely cant be modifying the string right ? its just copying certain characters over? That snippet is not modifying line_in[], but I can't see how the while loop terminates. From 00014979@csse.uwa.edu.au Fri Sep 11 04:38:23 2015 Date: Fri Sep 11 04:38:23 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Project 1 Testing and Validation From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hi Jake. > I have got a prototype like this: > > int mystrtok(char line[],int n) > { > int length = sizeof(line); The value of length will 'always' be incorrect; if you print it out, it will likely always be 4 (described in lectures next week). You'll need to pass the known length of the array to your function. From kahwan01@csse.uwa.edu.au Fri Sep 11 10:25:25 2015 Date: Fri Sep 11 10:25:25 2015 To: help2002@csse.uwa.edu.au Received: from 123.3.96.187 Subject: xcode SDK From: "Nerces Kahwajian" <21592645@student.uwa.edu.au> X-smilie: none X-img: none Good morning Chris, I have a quick question. Do the computers in CSSE Lab 2.01 have the Xcode SDK installed on them? I'll be going in to uni shortly to test run my code, but I thought I would ask here anyway and see if I can get a reply before I leave! Reason I'm asking is because I'm trying to use 'strsep' but as you will know, it's not in the c99 standard. Thanks in advance! From 00014979@csse.uwa.edu.au Fri Sep 11 10:58:36 2015 Date: Fri Sep 11 10:58:36 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: xcode SDK From: "Christopher McDonald" X-smilie: none X-img: none "Nerces Kahwajian" <21592645@student.uwa.edu.au> wrote: > Good morning Chris, > > I have a quick question. Do the computers in CSSE Lab 2.01 have the Xcode SDK installed on > them? I'll be going in to uni shortly to test run my code, but I thought I would ask here > anyway and see if I can get a reply before I leave! > > Reason I'm asking is because I'm trying to use 'strsep' but as you will know, it's not in > the c99 standard. OS-X in 2.01 does have Xcode installed (though it's not usually described as an SDK, but as an IDE). Students have been using it, or the portion of it that provides the command-line tools. While we are focussing on using C99 correctly, that doesn't imply that we're *only* using things in the C99 standard library. Apple places strsep() in its standard (default) C library - however, the function strsep() has many of the same 'dangers' as strtok(). It's really only a 20-line function, that you'll probably learn a lot from, by writing a version that doesn't modify the input string. From kahwan01@csse.uwa.edu.au Fri Sep 11 11:02:59 2015 Date: Fri Sep 11 11:02:59 2015 To: help2002@csse.uwa.edu.au Received: from 123.3.96.187 Subject: xcode SDK From: "Nerces Kahwajian" <21592645@student.uwa.edu.au> X-smilie: none X-img: none Thanks for your swift reply Chris and for the clarification of it being an IDE. I guess I'll have to look into writing my own function then as I just ran into a small issue with strsep. From kahwan01@csse.uwa.edu.au Fri Sep 11 11:23:57 2015 Date: Fri Sep 11 11:23:57 2015 Edit: Fri Sep 11 11:33:16 2015 To: help2002@csse.uwa.edu.au Received: from 123.3.96.187 Subject: Error in the stop.txt formatting? From: "Nerces Kahwajian" <21592645@student.uwa.edu.au> X-smilie: none X-img: none EDIT: Someone cleared up that commas are allowed. So I need to modify my code. Definitely not a problem with the GTFS! Good morning again Chris! I was running my code and testing my outputs, everything seems fine except for 1 line. This specific line has a comma between the name of the stop and is causing errors in my printout. From what I know the GTFS standards ask you to have a - in between instead of a comma. This is the line in question (11th last line): 1,,117,117,"Adelaide Tce, Westend Causeway",,-31.96184151126730,115.878219921897, Notice how "Adelaide Tce, Westend Causeway" has a comma in between Tce and Westend. And when I print the output, it gives me: 117 | "Adelaide Tce | | -31.96184151126730 When it's meant to give: Stop_ID | Stop_Name | Stop_Lat | Stop_Lon Instead it is giving: Stop_ID | Stop_Name | | Stop_Lat NB: Every other line prints correctly, this is the only line having this issue. Thanks again! If you need me to clear anything up, don't hesitate to ask as I know that was horribly written. From 00014979@csse.uwa.edu.au Fri Sep 11 11:33:54 2015 Date: Fri Sep 11 11:33:54 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Error in the stop.txt formatting? From: "Christopher McDonald" X-smilie: none X-img: none Hi Nerces, > Notice how "Adelaide Tce, Westend Causeway" has a comma in between Tce and Westend. I strongly believe that that's a correctly formatted line. The reason that that field has double-quotes around it is to indicate that everything until the next double-quote is part of the field. The quotes are 'hiding' any special meaning of what's between them. I agree that only having one such instance is a bit weird, but it's consistent with many other aspects of text and commands. In the shell, at the prompt, consider the two valid command-lines: a=b clear and a="b clear" See also the section entitled File Requirements in https://developers.google.com/transit/gtfs/reference#file-requirements (I'm always wondering if anyone's noticed that some time fields have hour values of 25: , 26: , and 27: ) From kahwan01@csse.uwa.edu.au Fri Sep 11 11:36:40 2015 Date: Fri Sep 11 11:36:40 2015 To: help2002@csse.uwa.edu.au Received: from 123.3.96.187 Subject: Error in the stop.txt formatting? From: "Nerces Kahwajian" <21592645@student.uwa.edu.au> X-smilie: none X-img: none Thanks again for the quick reply Chris! Someone mentioned that I'll have to code a check for it. I haven't even got to that part yet! I feel a little behind now. From jennib03@csse.uwa.edu.au Fri Sep 11 13:07:20 2015 Date: Fri Sep 11 13:07:20 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.225.60 Subject: Error in the stop.txt formatting? From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > (I'm always wondering if anyone's noticed that some time fields have hour values of 25: , 26: , and 27: > ) I am now. :/ I assume that indicates the next day? I.e., for trains? From 00014979@csse.uwa.edu.au Fri Sep 11 13:57:43 2015 Date: Fri Sep 11 13:57:43 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Error in the stop.txt formatting? From: "Christopher McDonald" X-smilie: none X-img: none "Benjamin Jennings" <21460003@student.uwa.edu.au> wrote: > I am now. :/ I assume that indicates the next day? I.e., for trains? haven't investigated - find them with grep ',2[5-7]:' *txt e.g. trip_id 624168 is a bus from Fremantle to Rockingham and 683024 a train from Perth to Mandurah. From jennib03@csse.uwa.edu.au Fri Sep 11 16:11:48 2015 Date: Fri Sep 11 16:11:48 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.225.60 Subject: Opening the transit folder From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > No; don't (and there's no need) to make that assumption. > It could be anywhere. In *not* making this assumption, we only need for the program to check if a folder exists at a relative *and* an absolute path right? I.e., it will either be at a relative path and the input would be: prompt> /.whichbus folder/path/to/gtfs-data lat long lat long Or at an absolute path, for example: prompt> /.whichbus /usr/user/gtfs-data Or am I missing a possible option? From newmal01@csse.uwa.edu.au Fri Sep 11 18:32:38 2015 Date: Fri Sep 11 18:32:38 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.132 Subject: Stoptimes.txt From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none i am trying to open the file stop_times.txt however when i use the fgets funtion winthin a while loop and aading each value to repective arrays i recieve the following segmentation fault 11 usually after about 100 to 300 time depending on the number of declaration and function called within in the while loop however if i do the exact same thing for the stops.txt it runs perfectly fine? From 00014979@csse.uwa.edu.au Fri Sep 11 19:12:07 2015 Date: Fri Sep 11 19:12:07 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Opening the transit folder From: "Christopher McDonald" X-smilie: none X-img: none "Benjamin Jennings" <21460003@student.uwa.edu.au> wrote: > "Christopher McDonald" wrote: > > > No; don't (and there's no need) to make that assumption. > > It could be anywhere. > > In *not* making this assumption, we only need for the program to check if a folder exists at a > relative *and* an absolute path right? You don't need to check *anything*. Your program will try to open, say, the file "doesnotexist/stops.txt", and the opening will fail. From 00014979@csse.uwa.edu.au Fri Sep 11 19:23:13 2015 Date: Fri Sep 11 19:23:13 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Stoptimes.txt From: "Christopher McDonald" X-smilie: none X-img: none You've not provided enough information to diagnose the problem. There's only 3 possible cases: it fails on the first call to gets(), if fails after some 'random' number of calls, or it reads the whole file successfully. As yours is the 2nd case, it suggests that you're doing something wrong during each iteration, which eventually 'compound' to form the error. First, eliminate (comment out) what you're doing *inside* the loop, and just ensure that you can read the whole file without error, or perhaps just count the number of lines in the file. From jennib03@csse.uwa.edu.au Fri Sep 11 23:01:21 2015 Date: Fri Sep 11 23:01:21 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.225.60 Subject: Opening the transit folder From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > You don't need to check *anything*. > Your program will try to open, say, the file "doesnotexist/stops.txt", and the opening will fail. Ah yes, of course! -facepalm- From fetzee01@csse.uwa.edu.au Sat Sep 12 08:20:48 2015 Date: Sat Sep 12 08:20:48 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: program to test output From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > when will the program to test the output be released? Bump From nelsoj07@csse.uwa.edu.au Sat Sep 12 10:23:45 2015 Date: Sat Sep 12 10:23:45 2015 To: help2002@csse.uwa.edu.au Received: from 60.228.150.126 Subject: program to test output From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: thumbup.png X-img: none This obviously isn't the official program, or anything near it, but I've written an alias to test 20 valid journeys that have no transfers. Name the folder that the Transperth GTFS data is in Transperth and put it in the same directory as whichbus.c and you should be good to go! Add this alias to your bash configuration file, as shown in the first Tutorial. Once added type testRoutes at the terminal and run! It will store the results of each test in a .txt file in a folder named OUTPUT. alias testRoutes='mkdir OUTPUT; ./whichbus transperth -31.954131 115.858761 -31.978690 115.819842 > OUTPUT/001_CITY_UWA.txt; ./whichbus transperth -31.978690 115.819842 -31.954131 115.858761 > OUTPUT/002_UWA_CITY.txt; ./whichbus transperth -31.954131 115.858761 -31.745387 115.767455 > OUTPUT/003_CITY_JOONDALUP.txt; ./whichbus transperth -31.745387 115.767455 -31.954131 115.858761 > OUTPUT/004_JOONDALUP_CITY.txt; ./whichbus transperth -31.978690 115.819842 -31.902577 115.800413 > OUTPUT/005_UWA_INNALOO.txt; ./whichbus transperth -31.902577 115.800413 -31.978690 115.819842 > OUTPUT/006_INNALOO_UWA.txt; ./whichbus transperth -31.954131 115.858761 -32.051689 115.745280 > OUTPUT/007_CITY_FREMANTLE.txt; ./whichbus transperth -32.051689 115.745280 -31.954131 115.858761 > OUTPUT/008_FREMANTLE_CITY.txt; ./whichbus transperth -31.954131 115.858761 -31.968768 115.813493 > OUTPUT/009_CITY_HOSPITAL.txt; ./whichbus transperth -31.968768 115.813493 -31.954131 115.858761 > OUTPUT/010_HOSPITAL_CITY.txt; ./whichbus transperth -31.954131 115.858761 -31.982185 115.779988 > OUTPUT/011_CITY_CLAREMONT.txt; ./whichbus transperth -31.982185 115.779988 -31.954131 115.858761 > OUTPUT/012_CLAREMONT_CITY.txt; ./whichbus transperth -31.978690 115.819842 -31.982185 115.779988 > OUTPUT/013_UWA_CLAREMONT.txt; ./whichbus transperth -31.982185 115.779988 -31.978690 115.819842 > OUTPUT/014_CLAREMONT_UWA.txt; ./whichbus transperth -31.982185 115.779988 -31.968768 115.813493 > OUTPUT/015_CLAREMONT_HOSPITAL.txt; ./whichbus transperth -31.968768 115.813493 -31.982185 115.779988 > OUTPUT/016_HOSPITAL_CLAREMONT.txt; ./whichbus transperth -31.978690 115.819842 -31.968768 115.813493 > OUTPUT/017_UWA_HOSPITAL.txt; ./whichbus transperth -31.968768 115.813493 -31.978690 115.819842 > OUTPUT/018_HOSPITAL_UWA.txt; ./whichbus transperth -32.051689 115.745280 -31.902577 115.800413 > OUTPUT/019_FREMANTLE_INNALOO.txt; ./whichbus transperth -31.902577 115.800413 -32.051689 115.745280 > OUTPUT/020_INNALOO_FREMANTLE.txt' From fetzee01@csse.uwa.edu.au Sat Sep 12 12:29:38 2015 Date: Sat Sep 12 12:29:38 2015 Edit: Sat Sep 12 12:32:04 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: program to test output From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > This obviously isn't the official program, or anything near it, but I've written an > alias to test 20 valid journeys that have no transfers. Name the folder that the > Transperth GTFS data is in Transperth and put it in the same directory as whichbus.c > and you should be good to go! > > Add this alias to your bash configuration file, as shown in the first Tutorial. Once > added type testRoutes at the terminal and run! It will store the results of each > test in a .txt file in a folder named OUTPUT. > > alias testRoutes='mkdir OUTPUT; ./whichbus transperth -31.954131 115.858761 > -31.978690 115.819842 > OUTPUT/001_CITY_UWA.txt; ./whichbus transperth -31.978690 > 115.819842 -31.954131 115.858761 > OUTPUT/002_UWA_CITY.txt; ./whichbus transperth > -31.954131 115.858761 -31.745387 115.767455 > OUTPUT/003_CITY_JOONDALUP.txt; > ./whichbus transperth -31.745387 115.767455 -31.954131 115.858761 > > OUTPUT/004_JOONDALUP_CITY.txt; ./whichbus transperth -31.978690 115.819842 > -31.902577 115.800413 > OUTPUT/005_UWA_INNALOO.txt; ./whichbus transperth -31.902577 > 115.800413 -31.978690 115.819842 > OUTPUT/006_INNALOO_UWA.txt; ./whichbus transperth > -31.954131 115.858761 -32.051689 115.745280 > OUTPUT/007_CITY_FREMANTLE.txt; > ./whichbus transperth -32.051689 115.745280 -31.954131 115.858761 > > OUTPUT/008_FREMANTLE_CITY.txt; ./whichbus transperth -31.954131 115.858761 > -31.968768 115.813493 > OUTPUT/009_CITY_HOSPITAL.txt; ./whichbus transperth > -31.968768 115.813493 -31.954131 115.858761 > OUTPUT/010_HOSPITAL_CITY.txt; > ./whichbus transperth -31.954131 115.858761 -31.982185 115.779988 > > OUTPUT/011_CITY_CLAREMONT.txt; ./whichbus transperth -31.982185 115.779988 > -31.954131 115.858761 > OUTPUT/012_CLAREMONT_CITY.txt; ./whichbus transperth > -31.978690 115.819842 -31.982185 115.779988 > OUTPUT/013_UWA_CLAREMONT.txt; > ./whichbus transperth -31.982185 115.779988 -31.978690 115.819842 > > OUTPUT/014_CLAREMONT_UWA.txt; ./whichbus transperth -31.982185 115.779988 -31.968768 > 115.813493 > OUTPUT/015_CLAREMONT_HOSPITAL.txt; ./whichbus transperth -31.968768 > 115.813493 -31.982185 115.779988 > OUTPUT/016_HOSPITAL_CLAREMONT.txt; ./whichbus > transperth -31.978690 115.819842 -31.968768 115.813493 > > OUTPUT/017_UWA_HOSPITAL.txt; ./whichbus transperth -31.968768 115.813493 -31.978690 > 115.819842 > OUTPUT/018_HOSPITAL_UWA.txt; ./whichbus transperth -32.051689 > 115.745280 -31.902577 115.800413 > OUTPUT/019_FREMANTLE_INNALOO.txt; ./whichbus > transperth -31.902577 115.800413 -32.051689 115.745280 > > OUTPUT/020_INNALOO_FREMANTLE.txt' Thank you very much Jake, very helpful indeed. If you don't mind, could you possibly post a link to a file containing your output results? or even just post them here : ) Some of my results take less than 1 second to produce output.. But I am not entirely correct yet, only for some of them, how about you? From nelsoj07@csse.uwa.edu.au Sat Sep 12 14:48:11 2015 Date: Sat Sep 12 14:48:11 2015 To: help2002@csse.uwa.edu.au Received: from 121.215.42.30 Subject: program to test output From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none My program takes between 20 and 100 seconds to run, depending on where it is checking, how many stops in the area etc. I'll attach a zip file containing the output I get running testRoutes for Friday 09:00. However I wrote a day check to check if the service runs and haven't removed it yet, so there might be some differences. You could also use the Transperth site to try and validate your output :) Here is the zipped OUTPUT folder: https://www.dropbox.com/s/0i4fcu1228jaxug/OUTPUT.zip?dl=0 From newmal01@csse.uwa.edu.au Sat Sep 12 15:38:10 2015 Date: Sat Sep 12 15:38:10 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.127 Subject: more information to diagnose From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none I know we are not meant to use this forum as a debuggin terminal but i have tried everything and nothing is working it continuously runs perfectly if no function are called or array values are assigned #include #include #include #include #include #include #include #define STOPTIMES "/Users/21107195/Desktop/google_transit2/stop_times.txt" #define STOPS "/Users/21107195/Desktop/google_transit2/stops.txt" double getlat(int comstop_id); int main(){ int stop_id; int trip_id; int ahour; int amin; int asec; FILE *stop_times; stop_times=fopen(STOPTIMES,"r"); char line[BUFSIZ]; int count=0; while(fgets(line,sizeof line, stop_times)!=NULL){ if(count>0){ printf("%d.\n",count); sscanf(line,"%d,%d:%d:%d,%*d:%*d:%*d,%d,%*d,%*d,%*d,%*d",&trip_id,&ahour,&amin,&asec,&sto p_id); printf("stop id:%d\n",stop_id); printf("time:%d:%d:%d\n",ahour,amin,asec); printf("trip id:%d\n",trip_id); printf("%d.lat of stop id:%d is:%lf\n",count,stop_id,getlat(stop_id)); } count++; } } double getlat(int comstop_id){ int stop_id; double stop_lat; FILE *stops; stops=fopen(STOPS,"r"); char line[BUFSIZ]; int count=0; while(fgets(line, sizeof line, stops)!=NULL){ if(count>0){ if(isdigit(line[2])){ sscanf(line,"%*d,%*d,%d,%*d,%*100[^,],%*100[^,],%lf,%*lf,%*s",&stop_id,&stop_lat); } else{ sscanf(line,"%*d,,%d,%*d,%*100[^,],%*100[^,],%lf,%*lf,%*s",&stop_id,&stop_lat); } if(stop_id==comstop_id){ break; } } count++; } return stop_lat; } PLEASE HELP could you maybe try running it? From fetzee01@csse.uwa.edu.au Sat Sep 12 15:50:09 2015 Date: Sat Sep 12 15:50:09 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: program to test output From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none Sorry I meant for how long to produce output for a single journey. Appreciated, also here is my output for CITY_UWA.txt (I set LEAVEHOME to Wed 09:10) 09:10 walk 184m to stop 10224 "William St Stand 1" 09:14 catch bus 950 to stop 10388 "Mounts Bay Rd Before Winthrop Av" 09:26 walk 357m to destination 09:31 arrive Also, Chris' example on the project web page has 2 spaces between each word not enclosed in double quoutes I think we will have to make sure ours is the same (automatic marking) I am also worried about the distance. For example in mine, although same as yours in output, the distance is clearly being calulated different. I (like most people) am using haversines formula from tutorial 3, with a radius of earth set to 6371000m. I guess you are either calculating distance differently or you are using a slightly different commonly accepted radius of earth. When I complete it I can post a link to my output From 00014979@csse.uwa.edu.au Sat Sep 12 16:02:31 2015 Date: Sat Sep 12 16:02:31 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: program to test output From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > ANONYMOUS wrote: > > > when will the program to test the output be released? > > > Bump Yes; coming over the weekend. From 00014979@csse.uwa.edu.au Sat Sep 12 16:04:43 2015 Date: Sat Sep 12 16:04:43 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: more information to diagnose From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > I know we are not meant to use this forum as a debuggin terminal but i have tried There's always a 'but'. I suspect it's because you're never *closing* any opened files and, eventually, your process just can't open any more. This would/could have been identified if you were *checking* to see if the opening succeeded. From shahd06@csse.uwa.edu.au Sat Sep 12 17:18:39 2015 Date: Sat Sep 12 17:18:39 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.175.208 Subject: Take bus or train From: "Darpan Shah" <21460362@student.uwa.edu.au> X-smilie: none X-img: none In the example given in the project description it says we take the 98 bus but when I check the files it says that a train is closer to walk to. So how do we decide what mode of transport to take? From 00014979@csse.uwa.edu.au Sat Sep 12 17:32:35 2015 Date: Sat Sep 12 17:32:35 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Take bus or train From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > In the example given in the project description it says we take the 98 bus but when I check > the files it says that a train is closer to walk to. So how do we decide what mode of > transport to take? The example in the description is not a real/best one, but I will update it. The goal is to minimise time to the *final* destination, so you'd catch whichever gets you there quickest. From fetzee01@csse.uwa.edu.au Sat Sep 12 17:44:10 2015 Date: Sat Sep 12 17:44:10 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: Take bus or train From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > In the example given in the project description it says we take the 98 bus but when I check > > the files it says that a train is closer to walk to. So how do we decide what mode of > > transport to take? > > The example in the description is not a real/best one, but I will update it. > The goal is to minimise time to the *final* destination, so you'd catch whichever gets you there > quickest. the quickest is not a train, but the same bus which comes at an earlier time I think From jennib03@csse.uwa.edu.au Sat Sep 12 19:08:20 2015 Date: Sat Sep 12 19:08:20 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.225.60 Subject: Is stop_id always numeric? From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none https://developers.google.com/transit/gtfs/reference?hl=en#stops_fields I'm just seeking clarification on the spec as the link is not clear and I am unable to find clearer details; are *all* stop_id fields numeric for GTFS feeds? From 00014979@csse.uwa.edu.au Sat Sep 12 19:10:51 2015 Date: Sat Sep 12 19:10:51 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Is stop_id always numeric? From: "Christopher McDonald" X-smilie: none X-img: none The spec. doesn't say they are, and may not be numeric for other datasets. From chowda01@csse.uwa.edu.au Sat Sep 12 19:36:15 2015 Date: Sat Sep 12 19:36:15 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.112.22 Subject: How to compare time? From: "Anirban Chowdhury" <21432966@student.uwa.edu.au> X-smilie: none X-img: none Hi i am stuck as to how i can compare the time a bus is going to depart a particular stop to the time i get by adding $LEAVEHOME and walking time to know if i can make it to the particular bus stop before the bus passes by. I hope i could get my point across. Any help would be greatly appreciated. Thanks From jennib03@csse.uwa.edu.au Sat Sep 12 22:01:06 2015 Date: Sat Sep 12 22:01:06 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.225.60 Subject: Is stop_id always numeric? From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none Damn. Okay, thanks for clarifying. From newmal01@csse.uwa.edu.au Sat Sep 12 23:43:55 2015 Date: Sat Sep 12 23:43:55 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.127 Subject: Run TIme Innefficency From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none Hi i was wondering as to how long it would take in marking before the time limit would be exceeded and the program will exit as a failure is there a recommend maximum file size limit when it comes to using the fgets functin? also i am on the computers in the computer science building i am not sure if there are very slow? From 00014979@csse.uwa.edu.au Sun Sep 13 09:03:09 2015 Date: Sun Sep 13 09:03:09 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: How to compare time? From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hi i am stuck as to how i can compare the time a bus is going to depart a particular stop > to the time i get by adding $LEAVEHOME and walking time to know if i can make it to the > particular bus stop before the bus passes by. You need to ensure that you're representing time in something that can be easily compared and supports arithmetic. All input and output times are character sequences of the form HH:MM - not much use to us in that form. However, devise simple functions to convert HH:MM to an integer number of minutes, and minutes back to HH:MM, and life becomes much easier. From 00014979@csse.uwa.edu.au Sun Sep 13 09:03:58 2015 Date: Sun Sep 13 09:03:58 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Take bus or train From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > the quickest is not a train, but the same bus which comes at an earlier time I think Sorry, not sure what you're saying here. From 00014979@csse.uwa.edu.au Sun Sep 13 09:05:46 2015 Date: Sun Sep 13 09:05:46 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Is stop_id always numeric? From: "Christopher McDonald" X-smilie: none X-img: none "Benjamin Jennings" <21460003@student.uwa.edu.au> wrote: > Damn. Okay, thanks for clarifying. Yes, I felt that too; the spec only states that sequence numbers are ascending integers. I can imagine a short tram service having stop_ids of just A, B, C, .... From 00014979@csse.uwa.edu.au Sun Sep 13 09:24:29 2015 Date: Sun Sep 13 09:24:29 2015 Edit: Sun Sep 13 10:17:37 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Run TIme Innefficency From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hi i was wondering as to how long it would take in marking before the time limit would be > exceeded and the program will exit as a failure Please see: https://secure.csse.uwa.edu.au/run/help2002?p=np&a=227&all=y3 > is there a recommend maximum file size limit when it comes to using the fgets functin? The question doesn't really make sense. Once a file is open, fgets() can read it one line at a time - it does not read in, nor attempt to store, the whole file. > also i am on the computers in the computer science building i am not sure if there are very > slow? The iMacs are certainly ageing, but they're still as fast as the day we bought them. What may annoy you more is the network speed, which you can address by copying your files onto the machine's local hard-disk rather than reading them from the network-drive: prompt> mkdir /tmp/mystuff prompt> cp *.txt whichbus.c /tmp/mystuff prompt> cd /tmp/mystuff prompt> ... do your work here ... Edit: just made a simple comparison of my basic solution for a single-segment example: 2013 laptop with SSD (10.6sec), 2009 iMac with 7200RPM Sata (21.2sec), 2011 iMac in lab local /tmp (14.1sec) 2011 iMac in lab UNIWA drive (223.6sec) !! From fetzee01@csse.uwa.edu.au Sun Sep 13 11:02:18 2015 Date: Sun Sep 13 11:02:18 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: Take bus or train From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > the quickest is not a train, but the same bus which comes at an earlier time I think > > Sorry, not sure what you're saying here. Don't worry, this has been answered in the new example output you have posted. From ahmedm07@csse.uwa.edu.au Sun Sep 13 11:18:00 2015 Date: Sun Sep 13 11:18:00 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.1.126 Subject: Passing File Path as Parameter From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none Hey, So i am not sure if this has been answered before. I checked but couldn't see anything. Anyhow, I am assuming that the directory is given as a string so "/home/usr/name/gtfs/" and then we can add files names onto that. I am having trouble to actually get it from argv[] and store it into another array so i can use it as a string. I have had a search on the internet and argv[] is said to be array of pointers and not actually just a normal array. I am not sure if i understand what that means. Would love some input, feels like i am being stupid and overlooking something really simple. Thanks From 00014979@csse.uwa.edu.au Sun Sep 13 11:29:31 2015 Date: Sun Sep 13 11:29:31 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Passing File Path as Parameter From: "Christopher McDonald" X-smilie: none X-img: none Do the sample solutions for Labsheet-3 help? From lopasb03@csse.uwa.edu.au Sun Sep 13 11:46:03 2015 Date: Sun Sep 13 11:46:03 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.75.173 Subject: Using the LEAVEHOME environment variable and getting a segmentation fault From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Hi, I am having a problem using the environment variable LEAVEHOME in my function which converts a time in the form "Wed 12:30" into seconds. I have the following: #include #include #include #include #include #include #include #include int main(void) { int secondcount2(char * time2 ); const char *name = "LEAVEHOME"; char *value; value = getenv(name); char line [20]; strcpy(line,value); printf("environment variable is %s\n",line); printf("environment variable is %s\n",value); secondcount2(line); return 0; } The function works fine when I manually put in the LEAVEHOME character array, although not in the above case. Does anyone know if there if a trick or way to use the environment variable in a function? From nelsoj07@csse.uwa.edu.au Sun Sep 13 12:13:42 2015 Date: Sun Sep 13 12:13:42 2015 To: help2002@csse.uwa.edu.au Received: from 121.215.29.41 Subject: Using the LEAVEHOME environment variable and getting a segmentation fault From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none I got / get a segmentation fault if I set the $LEAVEHOME variable and then use another terminal window, different shell or anything like that, is that maybe what's happening? From bradfj01@csse.uwa.edu.au Sun Sep 13 12:19:05 2015 Date: Sun Sep 13 12:19:05 2015 To: help2002@csse.uwa.edu.au Received: from 60.224.9.24 Subject: Retrun Array From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none Having trouble with this, is there a certain way you can call a function to store a returned array in another array? for example... char tempArray [] = function(); I keep getting an error because I declare the tempArray in my function as a local variable. Am I doing something wrong or does C not allow this to occur. From ahmedm07@csse.uwa.edu.au Sun Sep 13 12:21:19 2015 Date: Sun Sep 13 12:21:19 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.1.126 Subject: Passing File Path as Parameter From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none I see that but if you are referring to the first problem and its solution. Isn't that just referencing the parameter in strlen function. I wanted to save each parameter to a variable. So basically, if i have argv[1] = "/home/usr/name/gtfs/" then i can save it in a different array and then add the file name to the end of it using a loop or something. So this is what i would get after the loop. "/home/usr/name/gtfs/stops.txt" which then i can use in my fopen method to reeference files. Is this the right idea? From chowda01@csse.uwa.edu.au Sun Sep 13 12:41:01 2015 Date: Sun Sep 13 12:41:01 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.112.22 Subject: How to compare time? From: "Anirban Chowdhury" <21432966@student.uwa.edu.au> X-smilie: none X-img: none Got it. Thanks a lot From nelsoj07@csse.uwa.edu.au Sun Sep 13 13:09:56 2015 Date: Sun Sep 13 13:09:56 2015 To: help2002@csse.uwa.edu.au Received: from 121.215.29.41 Subject: Passing File Path as Parameter From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none You could do for sure. If I understand what you mean then you want different strings for each file name, the folder and then append the relevant file name, i.e. transperth/routes.txt You could, using a few different approaches, store argv[1] as the first part of a string and then add the file name. Check out sprintf and read about the usage :) From lopasb03@csse.uwa.edu.au Sun Sep 13 13:10:39 2015 Date: Sun Sep 13 13:10:39 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.75.173 Subject: Using the LEAVEHOME environment variable and getting a segmentation fault From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > I got / get a segmentation fault if I set the $LEAVEHOME variable and then use another > terminal window, different shell or anything like that, is that maybe what's happening? That doesn't appear to be what is happening, does anyone else have any ideas? From nelsoj07@csse.uwa.edu.au Sun Sep 13 13:11:40 2015 Date: Sun Sep 13 13:11:40 2015 To: help2002@csse.uwa.edu.au Received: from 121.215.29.41 Subject: Retrun Array From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none I don't think you can initialise an array that way. Also in C you can't set an array to another array, maybe look at using a pointer or global variable instead? From nelsoj07@csse.uwa.edu.au Sun Sep 13 13:18:06 2015 Date: Sun Sep 13 13:18:06 2015 To: help2002@csse.uwa.edu.au Received: from 121.215.29.41 Subject: Using the LEAVEHOME environment variable and getting a segmentation fault From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Are you using the bash command given to set the LEAVEHOME variable? The code compiles and runs fine for me and prints out the LEAVEHOME variable as it's meant to (I think). The only thing I had to do was comment out the secondcount2(line) as I don't have that function. If I opened a new terminal and run the code, I get a segmentation fault. Setting the LEAVEHOME variable with bash export command it then runs fine, so I'm not sure how that's happening. From bradfj01@csse.uwa.edu.au Sun Sep 13 13:20:17 2015 Date: Sun Sep 13 13:20:17 2015 To: help2002@csse.uwa.edu.au Received: from 60.224.9.24 Subject: Retrun Array From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > I don't think you can initialise an array that way. Also in C you can't set an array to > another array, maybe look at using a pointer or global variable instead? Thank you Jake. From nelsoj07@csse.uwa.edu.au Sun Sep 13 13:38:50 2015 Date: Sun Sep 13 13:38:50 2015 To: help2002@csse.uwa.edu.au Received: from 121.215.29.41 Subject: Retrun Array From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none No problem, hope that helps! From lopasb03@csse.uwa.edu.au Sun Sep 13 13:56:13 2015 Date: Sun Sep 13 13:56:13 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.75.173 Subject: Using the LEAVEHOME environment variable and getting a segmentation fault From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > Are you using the bash command given to set the LEAVEHOME variable? The code compiles and runs fine > for me and prints out the LEAVEHOME variable as it's meant to (I think). The only thing I had to do > was comment out the secondcount2(line) as I don't have that function. > > If I opened a new terminal and run the code, I get a segmentation fault. Setting the LEAVEHOME > variable with bash export command it then runs fine, so I'm not sure how that's happening. Hey, I think your missing the point of what is happening with my code. The problem is with the line secondcount2(line), the way the above code is it prints out: environment variable is Sun 13:31 environment variable is Sun 13:31 Segmentation fault That means the code works fine up until secondcount2(line), but then for some reason I get a segmentation fault, which I don't get when I test my code manually? Here is how I have tried to fix it: #include #include #include #include #include #include #include #include int main(void) { int tmp2; int secondcount2(char time2[10] ); const char *name = "LEAVEHOME"; char *value; char line[20]; value = getenv(name); strcpy(line,value); printf("environment variable is %s\n",line);//int setsize; printf("environment variable is %s\n",value); tmp2 = secondcount2(line); if(tmp2) {printf("%d\n",tmp2);} else{ printf("%s does not work for some reason", line);} return 0; } But I still get the same error no matter which approach I take, I'm quite confused does anyone know what the problem may be? From nelsoj07@csse.uwa.edu.au Sun Sep 13 14:00:19 2015 Date: Sun Sep 13 14:00:19 2015 To: help2002@csse.uwa.edu.au Received: from 121.215.29.41 Subject: Using the LEAVEHOME environment variable and getting a segmentation fault From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Gotcha. Chris mentioned in another thread that this could be due to a file not benign closed and then running out of space, maybe check that thread and see if that could potentially be the problem? Without knowing more about the function I'm out of ideas sorry! From abusha02@csse.uwa.edu.au Sun Sep 13 14:01:12 2015 Date: Sun Sep 13 14:01:12 2015 To: help2002@csse.uwa.edu.au Received: from 220.253.171.201 Subject: Retrun Array From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > Having trouble with this, is there a certain way you can call a function to store a > returned array in another array? for example... > > char tempArray [] = function(); > > I keep getting an error because I declare the tempArray in my function as a local > variable. > > Am I doing something wrong or does C not allow this to occur. You can do this, but you'll need to use dynamic allocation. Firstly, you'll want to change that to a pointer, not an array (but you can treat them very similarly). Secondly, you obviously need to return a pointer, rather than an array. Thirdly, you need to consider what you're actually trying to do with your program's memory here. Consider: int main(void) { char *arr = function(); } char *function() { char test[] = ........... //Whatever you want to do with 'test' return test; //This is the important bit } What is actually happening in that return statement. If you think about it, you're returning a pointer to a an address in memory (since the array will decay into a pointer to its first element when passed as a parameter or return statement). Here's the problem: that memory that you're returning a pointer to belongs to the array 'test', which is a local variable to 'function.' Since it's a local variable, it is created on the stack, and when the function ends, you no longer know what's in that memory. So the pointer will successfully return, but it probably won't be pointing to what you intended. To get around this, you need to use dynamic memory allocation, and allocate memory on the heap for that array; that way you can reliably retrieve the data in that memory even after 'function' terminates. char *function() { char *test = (char *) malloc(SIZE); //Whatever you want to do with 'test' return test; //This will work now } To be honest, I'm not sure I'd recommend doing this, at least not until Chris explains it. Plus, there's a better way to achieve what you're trying to do, as long as you know how large you need to make the array. You can just pass the array as a parameter to the function, and let the function modify the array. So: int main(void) { char tempArray[MAXSIZE]; function(, tempArray); } That is a much better way of doing things, but it does require that you at least know the upper bound on your array's size at compile time. From lopasb03@csse.uwa.edu.au Sun Sep 13 14:30:00 2015 Date: Sun Sep 13 14:30:00 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.75.173 Subject: Using the LEAVEHOME environment variable and getting a segmentation fault From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: swear.png X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > Gotcha. Chris mentioned in another thread that this could be due to a file not benign closed and then running out of > space, maybe check that thread and see if that could potentially be the problem? > > Without knowing more about the function I'm out of ideas sorry! That is not the problem, nowhere in the program do I open a file, my function only tries to use the environment variable LEAVEHOME as an input. Anybody else have any ideas as to where I'm going wrong in this main section? Do I have to allocate space for the character array or something along those lines, I seem to have tried everything I can think of ?!? From lopasb03@csse.uwa.edu.au Sun Sep 13 14:46:18 2015 Date: Sun Sep 13 14:46:18 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.183.33 Subject: Using the LEAVEHOME environment variable and getting a segmentation fault From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: lol.png X-img: none ANONYMOUS wrote: > "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > > > Gotcha. Chris mentioned in another thread that this could be due to a file not benign closed and then running out of > > space, maybe check that thread and see if that could potentially be the problem? > > > > Without knowing more about the function I'm out of ideas sorry! > > That is not the problem, nowhere in the program do I open a file, my function only tries to use the environment variable > LEAVEHOME as an input. Anybody else have any ideas as to where I'm going wrong in this main section? Do I have to > allocate space for the character array or something along those lines, I seem to have tried everything I can think of ?!? SUCCESS!!! It seems I was'nt allocating enough space for the 'line' character, so I changed it from 20 to 100 characters and the compiler stopped displaying a segmentation fault. This seems quite strange to me given that the string only seems to be 8 or 9 characters long when it prints out. Does anyone know why you need so much extra space even though the string is in the form "Wed 12:30", I would be interested to know. #include #include #include #include #include #include #include #include int main(void) { int tmp2; int secondcount2(char *time2 ); const char *name = "LEAVEHOME"; char *value; char line[100]; value = getenv(name); strcpy(line,value); printf("environment variable is %s\n",line);//int setsize; printf("environment variable is %s\n",value); tmp2 = secondcount2(line); if(tmp2) {printf("\n");} else{ printf("%s does not work for some reason", line);} return 0; } From itlioj01@csse.uwa.edu.au Sun Sep 13 17:28:43 2015 Date: Sun Sep 13 17:28:43 2015 To: help2002@csse.uwa.edu.au Received: from 144.131.243.40 Subject: Question regarding LEAVEHOME From: "James Itliong" <21487513@student.uwa.edu.au> X-smilie: none X-img: none Hi, Does the total journey time start from the time stored in LEAVEHOME? I'm wondering if the time in LEAVEHOME is the exact time the person leaves the house or can the person leave a few minutes later so that when he/she leaves the house, he/she reaches the stop the same time as the arrival of the service (thus eliminating waiting time and therefore a shorter total journey time)? Thanks, James From newmal01@csse.uwa.edu.au Sun Sep 13 18:42:48 2015 Date: Sun Sep 13 18:42:48 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.139 Subject: Run TIme Innefficency From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none ok what i mean is there a recommended max limt size file which we should try to read at the start of the program fro example is reading every line of the stop_times.txt file not recommended? From newmal01@csse.uwa.edu.au Sun Sep 13 18:43:51 2015 Date: Sun Sep 13 18:43:51 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.139 Subject: Run TIme Innefficency From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > ok what i mean is there a recommended max limt size file which we should try to read at the start of the program > fro example is reading every line of the stop_times.txt file not recommended? >there is over 1000000 lines in the file? From curtie01@csse.uwa.edu.au Sun Sep 13 19:05:42 2015 Date: Sun Sep 13 19:05:42 2015 To: help2002@csse.uwa.edu.au Received: from 202.89.161.242 Subject: 1st command line argument? From: "Eoghan Curtin" <20938764@student.uwa.edu.au> X-smilie: none X-img: none Will this be the full path name of the file? As in where all of text files are located on the test pc. My program works when i give the full path name in the command line. I assume this must be the case but want final confirmation. thanks From nelsoj07@csse.uwa.edu.au Sun Sep 13 19:09:05 2015 Date: Sun Sep 13 19:09:05 2015 To: help2002@csse.uwa.edu.au Received: from 121.215.29.41 Subject: 1st command line argument? From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none I think Chris has addressed this in another help forum post, and from memory it shouldn't matter whther it's full or relative From 00014979@csse.uwa.edu.au Sun Sep 13 20:15:59 2015 Date: Sun Sep 13 20:15:59 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Run TIme Innefficency From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > ok what i mean is there a recommended max limt size file which we should try to read at the start of the program > fro example is reading every line of the stop_times.txt file not recommended? No; there's no limit nor magic maximum size that any file needs to be (yes, stop_times.txt is 1.17M lines long). And if you need to know/check all the information from a file then, yes, you need to read the whole file. But reading the file doesn't automatically mean *storing* all of the file's contents into your program's memory. That's certainly not required. From 00014979@csse.uwa.edu.au Sun Sep 13 20:18:33 2015 Date: Sun Sep 13 20:18:33 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Question regarding LEAVEHOME From: "Christopher McDonald" X-smilie: none X-img: none "James Itliong" <21487513@student.uwa.edu.au> wrote: > Hi, > > Does the total journey time start from the time stored in LEAVEHOME? I'm wondering if > the time in LEAVEHOME is the exact time the person leaves the house or can the person > leave a few minutes later so that when he/she leaves the house, he/she reaches the > stop the same time as the arrival of the service (thus eliminating waiting time and > therefore a shorter total journey time)? The whole journey's time is measured from the time in LEAVEHOME to the time you finally arrive at the destination. You can first stay 'at home' and wait, or arrive early wait at the first bustop, but the total time's the same. From 00014979@csse.uwa.edu.au Sun Sep 13 20:24:55 2015 Date: Sun Sep 13 20:24:55 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Using the LEAVEHOME environment variable and getting a segmentation fault From: "Christopher McDonald" X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > That means the code works fine up until secondcount2(line), but then for some reason I get a segmentation > fault, which I don't get when I test my code manually? Here is how I have tried to fix it: The problem is almost certainly to be in your secondcount2() function; the earlier code looks OK, although I cannot see any check to ensure that the environment variable is actually set. From 00014979@csse.uwa.edu.au Sun Sep 13 20:31:22 2015 Date: Sun Sep 13 20:31:22 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: 1st command line argument? From: "Christopher McDonald" X-smilie: none X-img: none "Eoghan Curtin" <20938764@student.uwa.edu.au> wrote: > Will this be the full path name of the file? As in where all of text files are > located on the test pc. The name of 'any' *directory*. cf: https://secure.csse.uwa.edu.au/run/help2002?p=np&a=397 From 00014979@csse.uwa.edu.au Sun Sep 13 20:33:46 2015 Date: Sun Sep 13 20:33:46 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Retrun Array From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > To be honest, I'm not sure I'd recommend doing this, at least not until Chris explains > it. Plus, there's a better way to achieve what you're trying to do, as long as you know > how large you need to make the array. You can just pass the array as a parameter to the > function, and let the function modify the array. So: > > int main(void) { > char tempArray[MAXSIZE]; > function(, tempArray); > } > > That is a much better way of doing things, but it does require that you at least know > the upper bound on your array's size at compile time. Yes; if Green Anonymous doesn't understand the explanation of Purple Anonymous, then the above advice is the simplest and best. The function() needs to know the actual length of tempArray, then that length should be passed as an additional parameter. From thompj20@csse.uwa.edu.au Mon Sep 14 01:34:51 2015 Date: Mon Sep 14 01:34:51 2015 To: help2002@csse.uwa.edu.au Received: from 60.224.118.25 Subject: Seconds From: "Joseph Thompson" <21517108@student.uwa.edu.au> X-smilie: none X-img: none After testing some code I get a slightly different answer to the sample output. 10:56:00 walk 316m to stop 10349 "Stirling Hwy After Wellington St" 11:04:00 catch bus 98 to stop 10381 "Mounts Bay Rd Opposite University Of Wa" 11:25:00 walk 618m to destination 11:35:18 arrive The code uses seconds, which seems to be the cause of the difference. The stops are one after another; from stop_times.txt 664494,11:23:00,11:23:00,10380,24,0,0,0 664494,11:25:00,11:25:00,10381,25,0,0,1 My program indicates that the second stop will get you there a few seconds faster, but this small change means the output is different. Is this output correct and what's expected in regards to seconds for the assignment? From 00014979@csse.uwa.edu.au Mon Sep 14 05:56:49 2015 Date: Mon Sep 14 05:56:49 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Seconds From: "Christopher McDonald" X-smilie: none X-img: none You'll note that no input data is only provided to the minute (always hh:mm:00), and the sample (required) output data is to the minute. From 00014979@csse.uwa.edu.au Mon Sep 14 09:24:29 2015 Date: Mon Sep 14 09:24:29 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: program to test output From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > when will the program to test the output be released? It's there now. Please see http://teaching.csse.uwa.edu.au/units/CITS2002/projects/project1-clarifications.php From nelsoj07@csse.uwa.edu.au Mon Sep 14 09:26:20 2015 Date: Mon Sep 14 09:26:20 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.235.222 Subject: program to test output From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: cyclop.png X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > when will the program to test the output be released? > > It's there now. > Please see http://teaching.csse.uwa.edu.au/units/CITS2002/projects/project1-clarifications.php Thanks! :) From hon06@csse.uwa.edu.au Mon Sep 14 09:31:18 2015 Date: Mon Sep 14 09:31:18 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.142.150 Subject: Seconds From: "Nathan Ho" <21506898@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > You'll note that no input data is only provided to the minute (always hh:mm:00), and the sample > (required) output data is to the minute. But then is there a convention we should use for rounding when considering the walking time? For example, a hypothetical comparison of seconds in our outputs; sample provided 11:23:00 walk 750m to destination 11:35:30 arrive ours 11:25:00 walk 618m to destination 11:35:18 arrive From 00014979@csse.uwa.edu.au Mon Sep 14 09:36:41 2015 Date: Mon Sep 14 09:36:41 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Seconds From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > But then is there a convention we should use for rounding when considering the walking time? Yes, round-up. There's no point being able to walk somewhere in 41 seconds, but then implying/calculating that you can do it in 0 minutes. From hon06@csse.uwa.edu.au Mon Sep 14 09:38:50 2015 Date: Mon Sep 14 09:38:50 2015 Edit: Mon Sep 14 09:40:25 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.142.150 Subject: Seconds From: "Nathan Ho" <21506898@student.uwa.edu.au> X-smilie: none X-img: none In following on from that; if two cases are tied (because of rounding up) which do we choose? Just the first one that comes up? From 00014979@csse.uwa.edu.au Mon Sep 14 09:42:56 2015 Date: Mon Sep 14 09:42:56 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Seconds From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Just the first one that comes up? I'm tempted to say that, but won't because the order of calculation/finding will possibly be different in each program. Projects will be checked (automatically) using examples that have been checked manually to avoid that type of problem arising. From nelsoj07@csse.uwa.edu.au Mon Sep 14 09:46:43 2015 Date: Mon Sep 14 09:46:43 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.235.222 Subject: Question regarding LEAVEHOME From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: question.png X-img: none Ah ok, so to clarify it is the shortest time from LEAVEHOME until arrival? Not the shortest time on public transport? So if LEAVEHOME is 10:00AM and the two possible trips are: 10:00 Walk 300m to stop 1 10:05 Catch route 10 to stop 2 10:25 Walk 300m to destination 10:30 Arrive Time from LEAVEHOME = 30 min | Time on transport = 20 min 10:25 Walk 60m to stop 3 10:26 Catch route 11 to stop 4 10:36 Walk 60m to destination 10:37 Arrive Time from LEAVEHOME = 37 min | Time on transport = 12 min Then the first trip would "win", be more efficient having the earlier arrival time? Just a little confused, I understood it as the smallest time on transport From 00014979@csse.uwa.edu.au Mon Sep 14 09:53:38 2015 Date: Mon Sep 14 09:53:38 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Question regarding LEAVEHOME From: "Christopher McDonald" X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > Ah ok, so to clarify it is the shortest time from LEAVEHOME until arrival? Not the shortest time on > public transport? > ...... > Then the first trip would "win", be more efficient having the earlier arrival time? Just a little > confused, I understood it as the smallest time on transport The project asks for "the "best" single-segment public transport route that should be taken to travel between the two locations." and the two locations (lat/lon) are your home and your final destination (not the lat/lon of the two bustops). From nelsoj07@csse.uwa.edu.au Mon Sep 14 10:04:56 2015 Date: Mon Sep 14 10:04:56 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.235.222 Subject: Question regarding LEAVEHOME From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Ok, so irrespective of when you actually leave home it is the earliest arrival time? Sorry just trying to clarify! From 00014979@csse.uwa.edu.au Mon Sep 14 10:24:59 2015 Date: Mon Sep 14 10:24:59 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Question regarding LEAVEHOME From: "Christopher McDonald" X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > Ok, so irrespective of when you actually leave home it is the earliest arrival time? Sorry just trying to clarify! The intention was/is that LEAVEHOME would imply the time at which you left home, and that would be the start of the whole journey. You can wait at home in the comfy chair, or on the cold metal bustop seat, but the whole journey time will be the same. From nelsoj07@csse.uwa.edu.au Mon Sep 14 10:33:24 2015 Date: Mon Sep 14 10:33:24 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.235.222 Subject: Question regarding LEAVEHOME From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: grin.png X-img: none Gotcha, thanks for the clarification! From 00014979@csse.uwa.edu.au Tue Sep 15 10:30:18 2015 Date: Tue Sep 15 10:30:18 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: A sample project solution (executable) now available From: "Christopher McDonald" X-smilie: none X-img: none X-announcefor: 5d See http://teaching.csse.uwa.edu.au/units/CITS2002/projects/project1-clarifications.php You can run it on CSSE lab machines, running either OS-X or Linux, with /cslinux/bin/whichbus-sample same-arguments-as-your-project.... From itlioj01@csse.uwa.edu.au Mon Sep 14 10:56:40 2015 Date: Mon Sep 14 10:56:40 2015 To: help2002@csse.uwa.edu.au Received: from 144.131.243.40 Subject: Question regarding LEAVEHOME From: "James Itliong" <21487513@student.uwa.edu.au> X-smilie: none X-img: none Alright, thanks! :) From bradfj01@csse.uwa.edu.au Mon Sep 14 15:39:14 2015 Date: Mon Sep 14 15:39:14 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.71.120 Subject: Retrun Array From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > To be honest, I'm not sure I'd recommend doing this, at least not until Chris explains > > it. Plus, there's a better way to achieve what you're trying to do, as long as you know > > how large you need to make the array. You can just pass the array as a parameter to the > > function, and let the function modify the array. So: > > > > int main(void) { > > char tempArray[MAXSIZE]; > > function(, tempArray); > > } > > > > That is a much better way of doing things, but it does require that you at least know > > the upper bound on your array's size at compile time. > > Yes; if Green Anonymous doesn't understand the explanation of Purple Anonymous, then the above > advice is the simplest and best. The function() needs to know the actual length of tempArray, > then that length should be passed as an additional parameter. Thank you I understand now, the code compiles fantastically. From newmal01@csse.uwa.edu.au Mon Sep 14 17:43:35 2015 Date: Mon Sep 14 17:43:35 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.134 Subject: extra marks From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none can we get extra marks for considering the condition of whether or not the trip is running to the specified day? From newmal01@csse.uwa.edu.au Mon Sep 14 17:44:43 2015 Date: Mon Sep 14 17:44:43 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.134 Subject: startup disk full From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none in the computer in the lab alot of them are freezing and running very slow it say that the startup disk is to full how can we clear the startup disk? From curtie01@csse.uwa.edu.au Mon Sep 14 18:36:37 2015 Date: Mon Sep 14 18:36:37 2015 To: help2002@csse.uwa.edu.au Received: from 202.89.161.242 Subject: 1st command line argument? From: "Eoghan Curtin" <20938764@student.uwa.edu.au> X-smilie: none X-img: none To be perfectly honest it's still not clear to me what you mean. For now I'm going to try use getcwd(Filedir) if (the first element in the directory string is not a /). In this case i only wont be able to find the files if they are not in your current directory & you don't specify where they are. From fetzee01@csse.uwa.edu.au Mon Sep 14 18:48:37 2015 Date: Mon Sep 14 18:48:37 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: program to test output From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > "Christopher McDonald" wrote: > > > ANONYMOUS wrote: > > > > > when will the program to test the output be released? > > > > It's there now. > > Please see http://teaching.csse.uwa.edu.au/units/CITS2002/projects/project1-clarifications.php > > Thanks! :) Thanks. So does the program only test the format of the output, and not the correctness itself? From 00014979@csse.uwa.edu.au Mon Sep 14 18:49:34 2015 Date: Mon Sep 14 18:49:34 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: 1st command line argument? From: "Christopher McDonald" X-smilie: none X-img: none "Eoghan Curtin" <20938764@student.uwa.edu.au> wrote: > To be perfectly honest it's still not clear to me what you mean. > > For now I'm going to try use getcwd(Filedir) if (the first element in the directory string is > not a /). In this case i only wont be able to find the files if they are not in your current > directory & you don't specify where they are. Your program does not have to *find* the data files - when you run your program you are *telling* your program where they are. When you provide, say, xxxxx as the 1st argument, your program will eventually try to open the file xxxxx/stops.txt If xxxxx does not name a valid directory, or one that you can't access, then the attempt to open the file will fail, and you program will (should) detect that. The directory xxxxx can be *anywhere* in the file-system - it does not have to be the current directory, or a directory that you own, or one with any particular relationship to the program. From 00014979@csse.uwa.edu.au Mon Sep 14 18:51:16 2015 Date: Mon Sep 14 18:51:16 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: program to test output From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Thanks. > So does the program only test the format of the output, and not the correctness itself? Yes; there'll be another to check correctness - it's probably finished but I've asked a few others to check it, too. From 00014979@csse.uwa.edu.au Mon Sep 14 18:52:59 2015 Date: Mon Sep 14 18:52:59 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: startup disk full From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > in the computer in the lab alot of them are freezing and running very slow > it say that the startup disk is to full > how can we clear the startup disk? Please email ithelp-ecm@uwa.edu.au indicating which computer(s) have the problem. Thanks. From 00014979@csse.uwa.edu.au Mon Sep 14 18:54:06 2015 Date: Mon Sep 14 18:54:06 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: extra marks From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > can we get extra marks for considering the condition of whether or not the trip is running > to the specified day? No; just as stated on the project sheet. (it's only about another 10 lines, isn't it?) From lopasb03@csse.uwa.edu.au Mon Sep 14 19:51:27 2015 Date: Mon Sep 14 19:51:27 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.75.173 Subject: Trip ID's "If" statement logic From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: nerd.png X-img: none Hi, I am trying to figure out the engine of my function that selects all the required trip ID's that are less then a 1000 m and less than an hour away from LEAVEHOME time and also less then the walking time required to walk to a particular stop. Here is the code I have so far: int b = 0,m = 0,n = 0; while(b < lines && m < Alength){ // lines equals the number of lines in the //text file, Alength equals the length of the stops < 1000m if(((stopnumberpointer[m] == stopid[b])) // FOR ABOVE: || All stop ID's < 1000m || && ((deptime[b]) - (timer) <= 3600) // || Less that one hours time away|| && ((deptime[b]) - (timer) <= storetime[m])){ // || Less than the walking time required away || tripids[n] = tripid[b]; n += 1; b += 1; m += 1; }else if(stopnumberpointer[m] != stopid[b]){ // The stopnumber is not //in the stop_times.txt file. m+=1; }else { b+=1; } } However, I am getting way too many trip_ID's, can anybody tell me if my logic for the if statement is a bit iffy, haha. Is there another "&&" I haven't considered, or am I going about it the wrong way? Any input would be appreciated. Thanks. From kahwan01@csse.uwa.edu.au Mon Sep 14 20:03:53 2015 Date: Mon Sep 14 20:03:53 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.131 Subject: Segmentation error From: "Nerces Kahwajian" <21592645@student.uwa.edu.au> X-smilie: none X-img: none What could be the reason for my code working on my laptop but when running it on the lab computers I get a segmentation error? Has anyone experienced this? From 00014979@csse.uwa.edu.au Mon Sep 14 20:24:14 2015 Date: Mon Sep 14 20:24:14 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Trip ID's "If" statement logic From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > if(((stopnumberpointer[m] == stopid[b])) >....... > }else if(stopnumberpointer[m] != stopid[b]){ // The stopnumber is not //in the > stop_times.txt file. The above 2 lines appear to be trying to compare 2 whole strings. In C you cannot compare strings using == or != . Instead you need to use the strcmp() function. From 00014979@csse.uwa.edu.au Mon Sep 14 20:27:29 2015 Date: Mon Sep 14 20:27:29 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Segmentation error From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > What could be the reason for my code working on my laptop but when running it on the lab > computers I get a segmentation error? Many possible reasons, so not able to give a definitive answer. Different platforms, OSs, versions, compilers..... will permit or allocate different amounts of memory to things. For example, one platform may permit, say, 1MB of global or local variables, whereas another may permit 8MB (just made up the numbers). You *may* be hoping that your program can read in many/all items in a file, and that may not be possible in the way you're trying. Does it happen immediately on program start, or after it's been running for a while? From lopasb03@csse.uwa.edu.au Mon Sep 14 20:30:12 2015 Date: Mon Sep 14 20:30:12 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.75.173 Subject: Trip ID's "If" statement logic From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > if(((stopnumberpointer[m] == stopid[b])) > >....... > > }else if(stopnumberpointer[m] != stopid[b]){ // The stopnumber is not //in the > > stop_times.txt file. > > The above 2 lines appear to be trying to compare 2 whole strings. > In C you cannot compare strings using == or != . > Instead you need to use the strcmp() function. But they are not strings, they are integers, is there an intcmp() function, or will strcmp() also compare two integers. I thought if they are integers, what i have would be fine? From 00014979@csse.uwa.edu.au Mon Sep 14 20:34:27 2015 Date: Mon Sep 14 20:34:27 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Trip ID's "If" statement logic From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > But they are not strings, they are integers, is there an intcmp() function, or will > strcmp() also compare two integers. I thought if they are integers, what i have would > be fine? OK, if they are integers, then the comparisons used will be OK, so ignore that suggestion. You cannot compare 2 integers with strcmp() - as it's name suggests it's for strings. However, as has been discussed in another thread, stop_id's are not integers, but are strings; hence my confusion. From lis63@csse.uwa.edu.au Mon Sep 14 20:38:26 2015 Date: Mon Sep 14 20:38:26 2015 Edit: Mon Sep 14 21:11:29 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.221.171 Subject: A strange bug. Never seen before. Need Help. From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none I create an array and use a function to set its values. As the array contains many variables, so I run the function in a loop. The problem is that in the function, the variables of the array are set correctly, but the next iteration in the loop will change the variable in former iterations. it's something like that: my_function(my_type* my_array, int i){ printf(my_array[0]); do something to my_array[i]; printf(my_array[0]); } for(int i=0;i X-smilie: none X-img: none On top of the max number of stops within 1000 metres, could we know the maximum number of routes connected to a stop? Would be helpful determining the size of a 2d array connecting stops to routes. Going with 100 to start off with, but I don't know if that is too small or way too large From 00014979@csse.uwa.edu.au Tue Sep 15 12:26:11 2015 Date: Tue Sep 15 12:26:11 2015 Edit: Tue Sep 15 12:33:31 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Max number of routes from one stop? From: "Christopher McDonald" X-smilie: none X-img: none Actually, I don't know that figure (and haven't needed to use it in the sample solution). Maybe someone has already determined it (but it would tie the program to the Transperth, or smaller, dataset). From gallj01@csse.uwa.edu.au Tue Sep 15 15:55:29 2015 Date: Tue Sep 15 15:55:29 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.112 Subject: Directory opening issues From: "James Gall" <21498933@student.uwa.edu.au> X-smilie: none X-img: none We've had some issues with our program regarding the same segmentation error mentioned in another topic. We found through debugging that if the program is run from inside the transperth directory, accessing the files without opening a directory, the program runs perfectly fine. It counts and processes all of the lines in the file without issue, and our print statements show all ~1.1 million lines counted and added to an array. That seems to mean that it's not a 'too much memory used' issue, which is what the internet has indicated segmentation error means. However, if we include the opening of the directory, the program crashes before even beginning to do anything with the files - literally as soon as the program has told us that the directory is valid and has been opened. Either the code is wrong, or there's some kind of permissions issue that is causing a problem. This is the code for opening the directory, where argv[1] is the directory name: DIR *pDir; pDir = opendir (argv[1]); //Make sure the directory is valid i.e. exists, spelled right, etc. if (pDir == NULL){ printf("Cannot open specified directory '%s'.\n", argv[1]); exit(EXIT_FAILURE); } printf( "Directory open success '%s'\n", argv[1]); The program crashes instantly after that final printf output. From 00014979@csse.uwa.edu.au Tue Sep 15 16:03:04 2015 Date: Tue Sep 15 16:03:04 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Directory opening issues From: "Christopher McDonald" X-smilie: none X-img: none The code you've provided works just fine for me (under OS-X) and for any correct or incorrect string value in argv[1]. The problem must be in other code. BUT - there is no need to open any directories for this project; just prepend the required directory name to each of the ssssss.txt files that you need to read. From 00014979@csse.uwa.edu.au Tue Sep 15 16:10:24 2015 Date: Tue Sep 15 16:10:24 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Max number of routes from one stop? From: "Christopher McDonald" X-smilie: insane.png X-img: none OK, I have an answer - the following inefficient shellscript took 95 minutes to run, but indicates that stop 10074 "Adelaide Tce After Hill St" has 2256 routes through it each week. cut -d, -f4 < stop_times.txt > f1 for s in `cut -d, -f4 < stops.txt` do echo `grep -c "^$s\$" < f1` $s done | sort -n From fetzee01@csse.uwa.edu.au Tue Sep 15 16:14:09 2015 Date: Tue Sep 15 16:14:09 2015 Edit: Tue Sep 15 16:17:25 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: Max number of routes from one stop? From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none Hi Chris, I am wondering how much of an issue memory usage is with the project? If our program runs in a small amount of time (5 seconds or something), but uses heaps of memory, but not enough to cause a stack overflow on the mac labs, is this acceptable? How many marks are likely to be deducted due to this type of inefficiency? Thank you. From 00014979@csse.uwa.edu.au Tue Sep 15 16:29:48 2015 Date: Tue Sep 15 16:29:48 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Max number of routes from one stop? From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hi Chris, I am wondering how much of an issue memory usage is with the project? If our program runs in > a small amount of time (5 seconds or something), but uses heaps of memory, but not enough to cause a > stack overflow on the mac labs, is this acceptable? How many marks are likely to be deducted due to > this type of inefficiency? Thank you. I imagine that your worst-case would be if you read all of the files into memory but, in total, we're only using about 50MB of data, which is not very much at all, and won't be examined for this project. You should also note that while speed is not an objective, the OS will read and cache most files for you "sometimes". See the second half of: https://secure.csse.uwa.edu.au/run/help2002?p=np&a=419 which shows that most speed-up comes, not from using lots of memory, but from avoiding the network-based file- system. From abusha02@csse.uwa.edu.au Tue Sep 15 16:32:32 2015 Date: Tue Sep 15 16:32:32 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.156.39 Subject: Strictness in marking test cases From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none Hi Chris. I've run multiple tests with the same set of coordinates and compared the output of the sample solution and my own. We both return the same path, however due to slight differences in some numbers (haversine formula, radius of earth, accounting for seconds in walking time etc.), I'm sometimes a minute off. i.e. you'll have an arrival time of 16:42, and I'll have an arrival time of 16:41. Will this cause the entire case to be marked as wrong, or is there a small leeway allowed for such minor inaccuracies/discrepancies? From 00014979@csse.uwa.edu.au Tue Sep 15 16:33:49 2015 Date: Tue Sep 15 16:33:49 2015 Edit: Tue Sep 15 16:35:34 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Strictness in marking test cases From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hi Chris. I've run multiple tests with the same set of coordinates and compared the > output of the sample solution and my own. We both return the same path, however due > to slight differences in some numbers (haversine formula, radius of earth, > accounting for seconds in walking time etc.), I'm sometimes a minute off. i.e. > you'll have an arrival time of 16:42, and I'll have an arrival time of 16:41. Will > this cause the entire case to be marked as wrong, or is there a small leeway allowed > for such minor inaccuracies/discrepancies? Small leeway - yes. Why choose a different Earth radius? [and glad we're getting the same results!] From abusha02@csse.uwa.edu.au Tue Sep 15 16:38:34 2015 Date: Tue Sep 15 16:38:34 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.156.39 Subject: Strictness in marking test cases From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none I'm not sure that it's a different earth radius; that was just an assumption as to what could be causing it. I'm just trying to stress that we have the same path, but our solution is 1 minute off yours. Since it's all auto marked, I was worried this would result in a 0 for that test case, despite everything more or less being correct. I think it's more to do with us not accounting for seconds in walking distance (i.e. distance of 659 metres would take about 11 minutes, but our program just truncates to 10, cause it's divided by 60). Will we lose marks for this 1 minute discrepancy? From 00014979@csse.uwa.edu.au Tue Sep 15 16:44:32 2015 Date: Tue Sep 15 16:44:32 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Strictness in marking test cases From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: it's more to do with us not accounting for seconds in walking distance (i.e. distance of > 659 metres would take about 11 minutes, but our program just truncates to 10, cause it's > divided by 60). Will we lose marks for this 1 minute discrepancy? I really can't see how, if choosing to calculate things in seconds, that you'd then choose to round down: https://secure.csse.uwa.edu.au/run/help2002?p=np&a=454 It doesn't make any physical sense. See the value of METRES_TO_MINS(m) on the Clarifications page. From abusha02@csse.uwa.edu.au Tue Sep 15 16:52:26 2015 Date: Tue Sep 15 16:52:26 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.156.39 Subject: Strictness in marking test cases From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none No worries. I didn't know we were rounding up. That fixes my values, and they now match yours. Thanks. From 00014979@csse.uwa.edu.au Tue Sep 15 16:59:55 2015 Date: Tue Sep 15 16:59:55 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Strictness in marking test cases From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > No worries. I didn't know we were rounding up. That fixes my values, and they now match yours. Thanks. Sounds good! Of interest, do you have one of those super-fast 1-second solutions, or something more laid back? From liaoj02@csse.uwa.edu.au Tue Sep 15 17:08:31 2015 Date: Tue Sep 15 17:08:31 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.166 Subject: Can't find sample solution From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none HI. Is the sample solution located in nextwork location -> (student number) -> linux? But I did not see cslinux Thanks. From graven01@csse.uwa.edu.au Tue Sep 15 17:18:28 2015 Date: Tue Sep 15 17:18:28 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Can't find sample solution From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none sample solution? i thought it wasnt due until friday... From liaoj02@csse.uwa.edu.au Tue Sep 15 17:24:09 2015 Date: Tue Sep 15 17:24:09 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.166 Subject: Can't find sample solution From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none see clarification? From fetzee01@csse.uwa.edu.au Tue Sep 15 17:35:32 2015 Date: Tue Sep 15 17:35:32 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: Strictness in marking test cases From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none Can someone please post some of the sample output from the sample solution so it can be tested against at home? (temporarily) This really would be appreciated. From 00014979@csse.uwa.edu.au Tue Sep 15 18:05:25 2015 Date: Tue Sep 15 18:05:25 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Can't find sample solution From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > HI. Is the sample solution located in nextwork location -> (student number) -> linux? It is an executable program named /cslinux/bin/whichbus-sample You can run it with: /cslinux/bin/whichbus-sample transperth lat1 lon1 lat2 lon2 From abusha02@csse.uwa.edu.au Tue Sep 15 18:08:41 2015 Date: Tue Sep 15 18:08:41 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.156.39 Subject: Strictness in marking test cases From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none No. I definitely wouldn't call my solution "super fast." It's very comparable to your own solution in terms of execution time. Additionally, I have one more query: I've noticed in my testing that there are some situations in which 2 journeys will actually have the exact same travel time (i.e. both journeys begin at 18:02 and arrive at the destination at 18:07). In this situation, I simply return the first journey I encounter, and in one case, that actually produced a very slightly different journey to your own program (but both were valid and had the same travel time). How will such an issue be treated in the marking? From fetzee01@csse.uwa.edu.au Tue Sep 15 19:22:18 2015 Date: Tue Sep 15 19:22:18 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: Strictness in marking test cases From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > No. I definitely wouldn't call my solution "super fast." It's very comparable to your own solution in terms > of execution time. Additionally, I have one more query: I've noticed in my testing that there are some > situations in which 2 journeys will actually have the exact same travel time (i.e. both journeys begin at > 18:02 and arrive at the destination at 18:07). In this situation, I simply return the first journey I > encounter, and in one case, that actually produced a very slightly different journey to your own program > (but both were valid and had the same travel time). How will such an issue be treated in the marking? Same case for me as well. From nelsoj07@csse.uwa.edu.au Tue Sep 15 19:26:18 2015 Date: Tue Sep 15 19:26:18 2015 To: help2002@csse.uwa.edu.au Received: from 1.122.96.154 Subject: Can't find sample solution From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Hey Chris, I'm getting the error "cannot open transperth/stops.txt", and I can't see a Transperth folder in the directory. Do you know why this might be? I've ssh'ed into one of the lab computers from home From abusha02@csse.uwa.edu.au Tue Sep 15 19:40:21 2015 Date: Tue Sep 15 19:40:21 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.156.39 Subject: Whichbus-check error with train names From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none Hi Chris. I think I've noticed an oversight with the checking program; either that or I'm an idiot. Train names are stored in the 'routes.txt' file as 2 words. For example "Joondalup line", "Mandurah line" etc. Conversely, bus route names and ferry route names are just one word (bus route names are obviously a number like 950). Your program, as well as our own, prints train route names as 2 words, but whichbus-check returns an error in response to this, as it seems to be expecting only one word. So: 19:11 catch rail 950 to stop 99612 "Esplanade Stn Platform 2" VALID 19:11 catch rail JoondalupLine to stop 99612 "Esplanade Stn Platform 2" VALID 19:11 catch rail Joondalup Line to stop 99612 "Esplanade Stn Platform 2" INVALID I can obviously change my output to print the train name as one word, but whichbus-sample (your own work) prints it as 2 words (and whichbus-check returns an error to your own output). Is this an error with whichbus-check, or an error with whichbus-sample. Could you please clarify whether or not we should print train names as one word? Thanks From lopasb03@csse.uwa.edu.au Tue Sep 15 19:58:57 2015 Date: Tue Sep 15 19:58:57 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.121.15 Subject: Run TIme Innefficency From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: disgusted.png X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > Hi i was wondering as to how long it would take in marking before the time limit would be > > exceeded and the program will exit as a failure > > Please see: https://secure.csse.uwa.edu.au/run/help2002?p=np&a=227&all=y3 > > > > is there a recommend maximum file size limit when it comes to using the fgets functin? > > The question doesn't really make sense. > Once a file is open, fgets() can read it one line at a time - it does not read in, nor attempt to store, > the whole file. > > > > also i am on the computers in the computer science building i am not sure if there are very > > slow? > > The iMacs are certainly ageing, but they're still as fast as the day we bought them. > What may annoy you more is the network speed, which you can address by copying your files onto the > machine's local hard-disk rather than reading them from the network-drive: > > prompt> mkdir /tmp/mystuff > prompt> cp *.txt whichbus.c /tmp/mystuff > prompt> cd /tmp/mystuff > prompt> ... do your work here ... > > > > Edit: just made a simple comparison of my basic solution for a single-segment example: > > 2013 laptop with SSD (10.6sec), > 2009 iMac with 7200RPM Sata (21.2sec), > 2011 iMac in lab local /tmp (14.1sec) > 2011 iMac in lab UNIWA drive (223.6sec) !! I still a little concerned about how long my program takes, will you leave our programs to run for at least 5 minutes? Mine takes about 70 seconds on a 2008 iMac G5, but I could probably speeds it up a little by tweeking it a bit. From fetzee01@csse.uwa.edu.au Tue Sep 15 20:14:38 2015 Date: Tue Sep 15 20:14:38 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: Whichbus-check error with train names From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none I was confused my self how to actually use whichbus-check in the first place. Do you mind telling how you tested with it? From 00014979@csse.uwa.edu.au Tue Sep 15 20:47:28 2015 Date: Tue Sep 15 20:47:28 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Whichbus-check error with train names From: "Christopher McDonald" X-smilie: none X-img: none "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> wrote: > Hi Chris. I think I've noticed an oversight with the checking program; either that > or I'm an idiot. Train names are stored in the 'routes.txt' file as 2 words. For > example "Joondalup line", "Mandurah line" etc. Conversely, bus route names and ferry > route names are just one word (bus route names are obviously a number like 950). > Your program, as well as our own, prints train route names as 2 words, but > whichbus-check returns an error in response to this, as it seems to be expecting > only one word. Thanks for reporting the problem; yes, the problem occurs because of the counting of the space-separated words. Interestingly the stop-names in the data files are enclosed in double quotes if they include a space, but rail names are not. So I think the easiest solution is to require that any multiple words containing a space are enclosed in double quotes (in reality, the rail names). So the sample solution now finds: ./whichbus . -31.747750, 115.766545 -31.952804, 115.854921 # -31.747750 115.766545 -31.952804 115.854921 # 41 stops within 1000m walk of start # 151 stops within 1000m walk of destination # 39 minutes: 14:00 walk 332m to stop 99871 "Joondalup Stn Platform 1" 14:07 catch rail "Joondalup Line" to stop 99602 "Perth Underground Stn Platform 2" 14:33 walk 336m to destination 14:39 arrive Does that seem the correct thing to you? The strchr() function will likely help you out. From 00014979@csse.uwa.edu.au Tue Sep 15 20:48:19 2015 Date: Tue Sep 15 20:48:19 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Whichbus-check error with train names From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > I was confused my self how to actually use whichbus-check in the first place. Do you > mind telling how you tested with it? You run: your-project ...... | /cslinux/bin/whichbus-check From 00014979@csse.uwa.edu.au Tue Sep 15 20:49:13 2015 Date: Tue Sep 15 20:49:13 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Can't find sample solution From: "Christopher McDonald" X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > Hey Chris, I'm getting the error "cannot open transperth/stops.txt", and I can't see a > Transperth folder in the directory. Do you know why this might be? I've ssh'ed into one of > the lab computers from home Even if running the sample solution, you still need to provide your own data files and then name their directory (nothing's changed). From 00014979@csse.uwa.edu.au Tue Sep 15 20:53:56 2015 Date: Tue Sep 15 20:53:56 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Run TIme Innefficency From: "Christopher McDonald" X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > I still a little concerned about how long my program takes, will you leave our programs to run for at least > 5 minutes? Mine takes about 70 seconds on a 2008 iMac G5, but I could probably speeds it up a little by > tweeking it a bit. Try your project on one of the CSSE machines, where it'll be marked, and you should find that it runs a quite a bit faster than your G5. Focus on your project's readability, and choice of good programming practices, rather than its speed. From fetzee01@csse.uwa.edu.au Tue Sep 15 20:58:30 2015 Date: Tue Sep 15 20:58:30 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: Whichbus-check error with train names From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none thank you. I was previously doing the same thing but using redirection instead of a pipe.. From krlevg01@csse.uwa.edu.au Tue Sep 15 21:25:08 2015 Date: Tue Sep 15 21:25:08 2015 To: help2002@csse.uwa.edu.au Received: from 180.216.50.90 Subject: Group Submission From: "Goce Krlevski" <21522548@student.uwa.edu.au> X-smilie: none X-img: none Hi I was wondering, if the project is done as a group, do we have to individually submit a copy or can one person submit as long as the code contains both names and student numbers? Thanks From tayi02@csse.uwa.edu.au Tue Sep 15 22:14:48 2015 Date: Tue Sep 15 22:14:48 2015 To: help2002@csse.uwa.edu.au Received: from 106.68.180.253 Subject: Group Submission From: "Ian Tay" <20939902@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > Hi I was wondering, if the project is done as a group, do we have to individually submit a > copy or can one person submit as long as the code contains both names and student numbers? > Thanks Usually one person submits the code on cssubmit (and the code contains both names and student numbers). From fetzee01@csse.uwa.edu.au Wed Sep 16 02:53:47 2015 Date: Wed Sep 16 02:53:47 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: project due date: 12:00 or 17:00? From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none Differences in cssubmit and the schedule web page. From 00014979@csse.uwa.edu.au Wed Sep 16 04:37:10 2015 Date: Wed Sep 16 04:37:10 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: project due date: 12:00 or 17:00? From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Differences in cssubmit and the schedule web page. Due 12 noon. Thanks. From 00014979@csse.uwa.edu.au Wed Sep 16 04:39:52 2015 Date: Wed Sep 16 04:39:52 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Whichbus-check error with train names From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > thank you. I was previously doing the same thing but using redirection instead of a pipe.. Great; this was described as "It reads your project's output either from its standard-input, or from a filename passed on the command-line", which means that you can also run: your-program ..... > tmpfile /cslinux/bin/whichbus-check tmpfile From 00014979@csse.uwa.edu.au Wed Sep 16 04:42:40 2015 Date: Wed Sep 16 04:42:40 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Group Submission From: "Christopher McDonald" X-smilie: none X-img: none If working in a team of two students, only one needs to submit the project. From 00014979@csse.uwa.edu.au Wed Sep 16 05:15:24 2015 Date: Wed Sep 16 05:15:24 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.182.205 Subject: Strictness in marking test cases From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > encounter, and in one case, that actually produced a very slightly different journey to your own program > (but both were valid and had the same travel time). How will such an issue be treated in the marking? Similar to this response, here: https://secure.csse.uwa.edu.au/run/help2002?p=np&a=456 From gallj01@csse.uwa.edu.au Wed Sep 16 12:05:34 2015 Date: Wed Sep 16 12:05:34 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.124 Subject: Directory opening issues From: "James Gall" <21498933@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > The code you've provided works just fine for me (under OS-X) and for any correct or incorrect string > value in argv[1]. The problem must be in other code. > > BUT - there is no need to open any directories for this project; just prepend the required directory > name to each of the ssssss.txt files that you need to read. Thanks, we totally passed over that solution. That'll help a lot. And I don't know where the problem with that old code comes in, because the crash occurs even with everything commented out except that block I posted. Doesn't really matter now. From abusha02@csse.uwa.edu.au Wed Sep 16 14:07:12 2015 Date: Wed Sep 16 14:07:12 2015 To: help2002@csse.uwa.edu.au Received: from 220.253.171.201 Subject: Project error messages (Chris please answer) From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none Hi Chris. Just a small question. Do we have to return the exact same error messages as the sample program to the letter, or are you mainly checking for the fact that we return a sensible error message and exit in the appropriate fashion? I can rewrite my error messages to match the sample program exactly, but I also recall you mentioning at one stage that for some things we should just use perror, so I'm not sure whether or not it's necessary to match your error messages word for word. Could you please clarify this? Thanks From zhangy56@csse.uwa.edu.au Wed Sep 16 14:19:13 2015 Date: Wed Sep 16 14:19:13 2015 To: help2002@csse.uwa.edu.au Received: from 180.216.60.20 Subject: same total journey time but different results(stops,walking time) From: "Yixin Zhang" <20866853@student.uwa.edu.au> X-smilie: cyclop.png X-img: none my result: 10:56 walk 950m to stop 10353 "Stirling Hwy After Stuart St" 11:06 catch bus 98 to stop 10381 "Mounts Bay Rd Opposite University Of Wa" 11:25 walk 619m to destination 11:36 arrive sample result: prompt> ./whichbus transperth -32.014402 115.758259 -31.981039 115.819120 10:56 walk 316m to stop 10349 "Stirling Hwy After Wellington St" 11:04 catch bus 98 to stop 10380 "Stirling Hwy After Clifton St" 11:23 walk 750m to destination 11:36 arrive Am I doing it wrong or is this acceptable? Will we be simply marked wrong if it is different from the sample solution? Thanks:) From fetzee01@csse.uwa.edu.au Wed Sep 16 14:52:22 2015 Date: Wed Sep 16 14:52:22 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.138 Subject: same total journey time but different results(stops,walking time) From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > my result: > 10:56 walk 950m to stop 10353 "Stirling Hwy After Stuart St" > 11:06 catch bus 98 to stop 10381 "Mounts Bay Rd Opposite University Of Wa" > 11:25 walk 619m to destination > 11:36 arrive > > > sample result: > prompt> ./whichbus transperth -32.014402 115.758259 -31.981039 115.819120 > 10:56 walk 316m to stop 10349 "Stirling Hwy After Wellington St" > 11:04 catch bus 98 to stop 10380 "Stirling Hwy After Clifton St" > 11:23 walk 750m to destination > 11:36 arrive > > > Am I doing it wrong or is this acceptable? Will we be simply marked wrong if it is > different from the sample solution? > > Thanks:) I have the exact same problem. I am glad I am not the only one. From fetzee01@csse.uwa.edu.au Wed Sep 16 15:13:00 2015 Date: Wed Sep 16 15:13:00 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.138 Subject: same total journey time but different results(stops,walking time) From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none I am having the same issue except here is my output: 10:56 walk 316m to stop 10349 "Stirling Hwy After Wellington St" 11:04 catch bus 98 to stop 10381 "Mounts Bay Rd Opposite University Of Wa" 11:25 walk 618m to destination 11:36 arrive From 00014979@csse.uwa.edu.au Wed Sep 16 15:57:25 2015 Date: Wed Sep 16 15:57:25 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: same total journey time but different results(stops,walking time) From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Am I doing it wrong or is this acceptable? Will we be simply marked wrong if it is > different from the sample solution? As has been stated a few times on the forum, we'll be aiming to only check with coordinates having a single solution. Moreover, the marking solution is able to print all possible but identical (time) solutions, so we can compare your single solution against each of those. From 00014979@csse.uwa.edu.au Wed Sep 16 15:59:48 2015 Date: Wed Sep 16 15:59:48 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Project error messages (Chris please answer) From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hi Chris. Just a small question. Do we have to return the exact same error messages > as the sample program to the letter, or are you mainly checking for the fact that we > return a sensible error message and exit in the appropriate fashion? I can rewrite > my error messages to match the sample program exactly, but I also recall you > mentioning at one stage that for some things we should just use perror, so I'm not > sure whether or not it's necessary to match your error messages word for word. Could > you please clarify this? Thanks Will (only) be looking for *some* output, and the correct error status. We cannot use perror() to report all kinds of errors, and it's only used for OS-interface related errors - for example, there's no perror() message for an environment variable not being defined; that's purely an application matter. From leongd02@csse.uwa.edu.au Wed Sep 16 16:53:37 2015 Date: Wed Sep 16 16:53:37 2015 Edit: Wed Sep 16 16:54:43 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.140 Subject: Running example coordinates on extended task on whichbus-sample From: "Dylan Leong" <21485566@student.uwa.edu.au> X-smilie: none X-img: none ayy i just ran the example coordinates on the project page for the extended task (-32.029674 115.755018 -31.981039 115.819120) on the whichbus-sample with the same LEAVEHOME (11.08), and it turns out that whichbus-sample finds a solution 1 minute faster that is only a single trip. Does the sample account for double segment routes, or is the project page extended example a 'lil old? just for clarification: On project page: 11:08 walk 305m to stop 99341 "North Fremantle Stn Platform 1" 11:15 catch rail "Fremantle Line" to stop 99281 "Claremont Stn Platform 1" 11:25 walk 165m to stop 19604 "Gugeri St Before Bay View Tce" 11:30 catch bus 102 to stop 26723 "Mounts Bay Rd After Hampden Road" 11:41 walk 620m to destination 11:51 arrive on whichbus-sample 11:08 walk 258m to stop 10345 "Stirling Hwy North Fremantle Stn" 11:17 catch bus 98 to stop 10381 "Mounts Bay Rd Opposite University Of Wa" 11:39 walk 618m to destination 11:50 arrive thanks in advance. edit: also does anyone know how to change your cits dp, a mate changed mine a year ago and i never really figured out how to change it back From serraj02@csse.uwa.edu.au Wed Sep 16 17:32:30 2015 Date: Wed Sep 16 17:32:30 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.129.215 Subject: New transperth data? From: "Joshua Serra" <21511988@student.uwa.edu.au> X-smilie: none X-img: none Hi, My partner and I have run into an issue were the same program was giving different outputs on each of our own machines. After re-downloading the transperth data it seems that the different output is now consistent leading us to believe that sometime between him and myself downloading the data transperth has made some changes. Can you clarify if there has been any changes and if the version of data we have makes any difference. Thanks From abusha02@csse.uwa.edu.au Wed Sep 16 18:27:22 2015 Date: Wed Sep 16 18:27:22 2015 To: help2002@csse.uwa.edu.au Received: from 220.253.171.201 Subject: Running example coordinates on extended task on whichbus-sample From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none Hi. I can't help you with your first question, but I can help you with your second (changing your avatar). On the help forum, select the 'options' drop down menu (near the top of the page, next to 'start a new topic'; it's the one that lets you filter out results). Right at the bottom, there's an option to change your preferences. You can change your avatar from within there. From led05@csse.uwa.edu.au Wed Sep 16 21:22:05 2015 Date: Wed Sep 16 21:22:05 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.52.130 Subject: function returning 2d char array From: "Henry Le" <21317911@student.uwa.edu.au> X-smilie: none X-img: none I've finished writing my program and compiling, I'm getting a "Incompatible pointer types" error. I basically want to return a variable that is a 2d array, what data type should I be putting in the function signature? Here's an example to illustrate my question (datatype??) myfunction(void) { char ans[2][2]; strcpy(ans[0], "hi"); strcpy(ans[0], "yo"); return ans; } From nelsoj07@csse.uwa.edu.au Wed Sep 16 21:24:00 2015 Date: Wed Sep 16 21:24:00 2015 To: help2002@csse.uwa.edu.au Received: from 60.230.195.113 Subject: function returning 2d char array From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none I don't think it's possible to return a 2D array from a function, so maybe a global 2D array would work instead? From led05@csse.uwa.edu.au Wed Sep 16 21:25:41 2015 Date: Wed Sep 16 21:25:41 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.52.130 Subject: function returning 2d char array From: "Henry Le" <21317911@student.uwa.edu.au> X-smilie: none X-img: none One fix i can think of is changing the function to a void that takes a 2D array and changes it From nelsoj07@csse.uwa.edu.au Wed Sep 16 21:29:20 2015 Date: Wed Sep 16 21:29:20 2015 To: help2002@csse.uwa.edu.au Received: from 60.230.195.113 Subject: function returning 2d char array From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Yep, instead of returning an array set it to something similar maybe: char ans[2][2]; void function ( void ) { strcpy(ans[0], "hi"); strcpy(ans[0], "yo"); } From led05@csse.uwa.edu.au Wed Sep 16 21:31:08 2015 Date: Wed Sep 16 21:31:08 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.52.130 Subject: function returning 2d char array From: "Henry Le" <21317911@student.uwa.edu.au> X-smilie: none X-img: none something like: void function ( char ans[2][2 ) { strcpy(ans[0], "hi"); strcpy(ans[0], "yo"); } should be fine right? From nelsoj07@csse.uwa.edu.au Wed Sep 16 21:35:55 2015 Date: Wed Sep 16 21:35:55 2015 To: help2002@csse.uwa.edu.au Received: from 60.230.195.113 Subject: function returning 2d char array From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Try it, I haven't used it that way before :) I don't think it'll work but I might be wrong! From abusha02@csse.uwa.edu.au Wed Sep 16 22:29:55 2015 Date: Wed Sep 16 22:29:55 2015 To: help2002@csse.uwa.edu.au Received: from 220.253.171.201 Subject: function returning 2d char array From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none Passing the array as an argument and modifying it within the function should work. There is one issue, though: you'll probably need to know how large the second dimension of the array is. For example: void function(char ans[][2]) VALID void function(char ans[][]) INVALID But if you already know the upper bound on the second dimension at compile time, then this should work fine. You don't *need* to use a global variable. As for returning an array from a function, you more or less need to use memory allocation for that, since you'd be returning a pointer. I'd wait for Chris to cover this before exploring that option. In fact, if passing the array as a parameter (as you've done in your example) is viable in whatever circumstance you're in, it's generally the best solution. From 00014979@csse.uwa.edu.au Thu Sep 17 04:23:11 2015 Date: Thu Sep 17 04:23:11 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.82.92 Subject: New transperth data? From: "Christopher McDonald" X-smilie: none X-img: none "Joshua Serra" <21511988@student.uwa.edu.au> wrote: > Can you clarify if there has been any changes and if the version of data we have > makes any difference. Yes, it does appear that a new data set was released on Sept 10th; however, provided you and your partner are both running with the same dataset, either old or new, it won't present any difficulties. From 00014979@csse.uwa.edu.au Thu Sep 17 04:26:24 2015 Date: Thu Sep 17 04:26:24 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.82.92 Subject: Running example coordinates on extended task on whichbus-sample From: "Christopher McDonald" X-smilie: none X-img: none "Dylan Leong" <21485566@student.uwa.edu.au> wrote: > Does the sample account for double segment routes, or is the project page extended > example a 'lil old? The sample solution only finds one-segment journeys; projects attempting two-segment journeys will not be automatically marked for the two-segments, but marked by hand (written somewhere else). The example on the project sheet is an example of the format (just copied from Transperth's webpage), and may not be the very best. From leongd02@csse.uwa.edu.au Thu Sep 17 08:51:16 2015 Date: Thu Sep 17 08:51:16 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.245.157 Subject: Running example coordinates on extended task on whichbus-sample From: "Dylan Leong" <21485566@student.uwa.edu.au> X-smilie: none X-img: none ahh ok, gotcha. Thanks to both of you : ) From coopea04@csse.uwa.edu.au Thu Sep 17 11:26:11 2015 Date: Thu Sep 17 11:26:11 2015 Edit: Thu Sep 17 11:27:11 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.140 Subject: 'inequality comparison result unused' in the second section of a for loop declaration From: "Adrian Cooper" <20786307@student.uwa.edu.au> X-smilie: none X-img: none project1.c:94:48: error: inequality comparison result unused [-Werror,-Wunused-comparison] for (int j = 0, int k = 0; routesfound[i][j] != 0; j++) { As you can see, it is exactly in the right place where such an inequality comparison should very much be used. It seems to be breaking the rest of the line by not being used, as well. From 00014979@csse.uwa.edu.au Thu Sep 17 11:38:24 2015 Date: Thu Sep 17 11:38:24 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: 'inequality comparison result unused' in the second section of a for loop declaration From: "Christopher McDonald" X-smilie: none X-img: none "Adrian Cooper" <20786307@student.uwa.edu.au> wrote: > project1.c:94:48: error: inequality comparison result unused > [-Werror,-Wunused-comparison] > for (int j = 0, int k = 0; routesfound[i][j] != 0; j++) { > > As you can see, it is exactly in the right place where such an inequality comparison should > very much be used. It seems to be breaking the rest of the line by not being used, as well. Which compiler are you using. I don't believe that you can have the second 'int' keyword there. From hon06@csse.uwa.edu.au Thu Sep 17 12:16:54 2015 Date: Thu Sep 17 12:16:54 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.130 Subject: Run TIme Innefficency From: "Nathan Ho" <21506898@student.uwa.edu.au> X-smilie: none X-img: none I know the focus isn't on efficiency; but is there some sort of maximum that will be considered too much? Compared to the times people are posting ours is very slow; 3 minutes and possibly more in dense areas... From adinam01@csse.uwa.edu.au Thu Sep 17 15:13:37 2015 Date: Thu Sep 17 15:13:37 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.95.161 Subject: function returning 2d char array From: "Manuchekhr Adina-Zada" <21135495@student.uwa.edu.au> X-smilie: none X-img: none You can make char** as your function data type. Then declare char** ans = malloc( ... ), then do the strcpy into ans. After that return ans. For some reason you can't return char arrays when declared as x[][], you can only return pointer to the allocated memory. Pretty sure that should work. From fetzee01@csse.uwa.edu.au Thu Sep 17 16:03:36 2015 Date: Thu Sep 17 16:03:36 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: many global defined constants? From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none Hello, I was wondering if having a large number of globally defined constants is considered "bad programming practice". (e.g. I currently have about 20, including constants to represent required files) For all I am told there aren't really any drawbacks and it shouldn't matter how many you define as long as they are used well/productively in the program. From johnsd16@csse.uwa.edu.au Thu Sep 17 16:27:15 2015 Date: Thu Sep 17 16:27:15 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.228.133 Subject: Poor teamwork. From: "Dylan Johnson" <21469038@student.uwa.edu.au> X-smilie: none X-img: none Is there anything we can do if our project partner isn't contributing much? From 00014979@csse.uwa.edu.au Thu Sep 17 17:09:02 2015 Date: Thu Sep 17 17:09:02 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Poor teamwork. From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Is there anything we can do if our project partner isn't contributing much? If the matter can't be resolved between the two of you, place a C comment near the top of your submission outlining the problems, and how each team member believes the marks should be split (if no longer 50/50). I will likely, then, discuss the problems with each team member. From 00014979@csse.uwa.edu.au Thu Sep 17 17:10:43 2015 Date: Thu Sep 17 17:10:43 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: many global defined constants? From: "Christopher McDonald" X-smilie: none X-img: none No, no real thing as too many (C preprocessor?) constants (unless they're redefining - #define ONE 1 ) Constants do not result in any additional memory being required (at runtime) as the compiler performs all the work in replacing references to them with their actual values. From 00014979@csse.uwa.edu.au Thu Sep 17 17:14:22 2015 Date: Thu Sep 17 17:14:22 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Run TIme Innefficency From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > I know the focus isn't on efficiency; but is there some sort of maximum that will be considered too much? Compared to the times > people are posting ours is very slow; 3 minutes and possibly more in dense areas... This really has been asked and answered several times. If your program is genuinely running for several minutes, when all of its required input files are on the computer's local/internal disk, then I'd encourage you to reconsider the design of your project, as it's probably not exhibiting good design, perhaps unnecessarily re- finding/searching or re-reading lots of data. From thompj20@csse.uwa.edu.au Thu Sep 17 17:41:35 2015 Date: Thu Sep 17 17:41:35 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.134 Subject: Sample code discrepancy From: "Joseph Thompson" <21517108@student.uwa.edu.au> X-smilie: none X-img: none When running a few test cases we find the sample output gets a different output to our own and a seemingly incorrect output; the input is as follows: newname:cits 21506898$ /cslinux/bin/whichbus-sample transperth -31.747750 115.766545 -31.952804 115.854921 # -31.747750 115.766545 -31.952804 115.854921 # 41 stops within 1000m walk of start # 151 stops within 1000m walk of destination # -1371 minutes: 22:56 walk 332m to stop 99871 "Joondalup Stn Platform 1" 23:44 catch rail "Joondalup Line" to stop 99602 "Perth Underground Stn Platform 2" 00:-1 walk 336m to destination 00:05 arrive newname:cits 21506898$ ./whichbus9 transperth -31.747750 115.766545 -31.952804 115.854921 | /cslinux/bin/whichbus-check 22:56 walk 332m to stop 99871 "Joondalup Stn Platform 1" 23:14 catch rail "Joondalup Line" to stop 99602 "Perth Underground Stn Platform 2" 23:40 walk 336m to destination 23:46 arrive with LEAVEHOME="Mon 22:56" We've manually checked our solution in the test files, and it appears valid. Could you please clarify this issue? From nelsoj07@csse.uwa.edu.au Thu Sep 17 17:53:27 2015 Date: Thu Sep 17 17:53:27 2015 To: help2002@csse.uwa.edu.au Received: from 60.230.195.113 Subject: Sample code discrepancy From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Assuming LEAVEHOME="Thu 22:56" then I get the same route as you do when ran: ./whichbus_draft transperth -31.747750 115.766545 -31.952804 115.854921 22:56 walk 332m to stop 99871 "Joondalup Stn Platform 1" 23:14 catch train "Joondalup Line" to stop 99602 "Perth Underground Stn Platform 2" 23:40 walk 336m to destination 23:46 arrive From 00014979@csse.uwa.edu.au Thu Sep 17 18:08:17 2015 Date: Thu Sep 17 18:08:17 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.82.92 Subject: Sample code discrepancy From: "Christopher McDonald" X-smilie: none X-img: none Should be fixed now. I was avoiding the midnight curfew by setting times after midnight to (-1). Then, code to find the minimum travel time was getting over-excited at finding trips of negative length! Thanks for reporting the problem. From fletca07@csse.uwa.edu.au Thu Sep 17 18:28:01 2015 Date: Thu Sep 17 18:28:01 2015 Edit: Thu Sep 17 19:05:24 2015 To: help2002@csse.uwa.edu.au Received: from 124.182.33.161 Subject: stoptimes.txt segmentation error From: "Alexander Fletcher" <21501626@student.uwa.edu.au> X-smilie: none X-img: none So I've tried to solve the figure this out but i just can't. FILE *stoptime = fopen("google_transit/stoptimes.txt","r"); char line[BUFSIZ]; while(fgets(line, sizeof line, stoptime)!=NULL){ } fclose(stoptime); Ive made it as concise as possible to try and find the issue,if i change it to stops.txt it works fine. I've tried putting a counter inside the loop but it doesn't print anything leading me to believe it is not working at all. Apologies if this is considered too debuggyish But some other people seemed to have a similar issue so hopefully someone can help thanks! edit:simple error....its been a long day From nelsoj07@csse.uwa.edu.au Thu Sep 17 18:30:29 2015 Date: Thu Sep 17 18:30:29 2015 To: help2002@csse.uwa.edu.au Received: from 60.230.195.113 Subject: stoptimes.txt segmentation error From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Is that exactly how your code is or is it stop_times.txt in your actual code? From 00014979@csse.uwa.edu.au Thu Sep 17 18:38:11 2015 Date: Thu Sep 17 18:38:11 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.82.92 Subject: stoptimes.txt segmentation error From: "Christopher McDonald" X-smilie: none X-img: none You'd find the error, and do better during the marking, by checking if the file opening was successful. From fletca07@csse.uwa.edu.au Thu Sep 17 18:53:23 2015 Date: Thu Sep 17 18:53:23 2015 Edit: Thu Sep 17 19:29:35 2015 To: help2002@csse.uwa.edu.au Received: from 124.182.33.161 Subject: stoptimes.txt segmentation error From: "Alexander Fletcher" <21501626@student.uwa.edu.au> X-smilie: none X-img: none my name was originally stop_times.txt but i was messing around with it to try and get it to work so quickly changed it back I seems i found the issue. That feel when u edit without going anonymous :C From fletca07@csse.uwa.edu.au Thu Sep 17 19:41:01 2015 Date: Thu Sep 17 19:41:01 2015 To: help2002@csse.uwa.edu.au Received: from 124.182.33.161 Subject: stoptimes.txt segmentation error From: "Alexander Fletcher" <21501626@student.uwa.edu.au> X-smilie: none X-img: none by the way it appears to have been cause by the environment variable being deleted From abusha02@csse.uwa.edu.au Thu Sep 17 20:03:57 2015 Date: Thu Sep 17 20:03:57 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.156.39 Subject: Different public transport data sets From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none Hi Chris. Different public transport data sets have completely different ways of storing stop ID's, route ID's, trip Id's etc. For example, Hobart's data set stores trip ID's as: "[@2.0.37377316@][1][1354150573046]/18", and route ID's as "H363". Darwin's data set stores stop ID's as "00BUS13" and trip ID's as "i1_21." Normally, my assumption as to your response would be "you need to account for that; you can't assume they're numbers," it seems your own sample solution doesn't actually work with these data sets. I tested several examples from both Darwin and Hobart, and your sample solution fails to recognize any stops. For example, for both of these data sets, I entered the lat and long values of two stops that were both on a trip that runs within 10 minutes of the current time (source lat and long being the first stop, and dest lat and long being the second stop). Your sample solution, however, returns "0 stops found within 1000m of source." Thus, it seems as though your sample solution can't recognize or work with these exotic formats for stop ID and trip ID. Are we, then, required to account for such? Our program assumes these ID's are numbers, and returns the exact same incorrect output as the sample solution when using Hobart and Darwin's data sets, which suggests you may have made the same assumption. Will you be using data sets with similar format to transperth, or is our program supposed to work with any possible GTFS data set thrown at it? From led05@csse.uwa.edu.au Thu Sep 17 20:43:21 2015 Date: Thu Sep 17 20:43:21 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.115 Subject: Abort trap 6 From: "Henry Le" <21317911@student.uwa.edu.au> X-smilie: none X-img: none Hey guys, When finding all the stops within a KM, i'm storing the entire line in a 2d character array, after testing, I find that the function simply stops after recording 40 lines and I get "Abort trap: 6" in terminal... In terms of the rest of my program, I think this is taking up all the memory and I can't store anything else... From 00014979@csse.uwa.edu.au Fri Sep 18 05:45:57 2015 Date: Fri Sep 18 05:45:57 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.82.92 Subject: Different public transport data sets From: "Christopher McDonald" X-smilie: none X-img: none "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> wrote: > Hi Chris. Different public transport data sets have completely different ways of > storing stop ID's, route ID's, trip Id's etc. > > For example, Hobart's data set stores trip ID's as: > "[@2.0.37377316@][1][1354150573046]/18", and route ID's as "H363". > > Darwin's data set stores stop ID's as "00BUS13" and trip ID's as "i1_21." The differences with those datasets (I have only looked at Hobart) is not that their ID are arbitrary strings, rather than integers, but that their fields are presented in a different order, and that some files have different and additional fields. Between Transperth and Hobart, their routes.txt are the same, but their stops, stop_times, and trips are each different. GTSF supports this because a very general/robust program reading these files would first read the header line, and then use the field names to determine what each field actually means. The sample solution does not, and your solution does not need to account for this! Every student's solution I've seen is (reasonably) just skipping the header line. (but get the columns right, and the sample solution still works :-) ./whichbus ../hobart -42.883680, 147.331788 -42.865008, 147.311246 # -42.883680 147.331788 -42.865008 147.311246 # 70 stops within 1000m walk of start # 76 stops within 1000m walk of destination # 18 minutes: 14:00 walk 181m to stop 2403 "Hobart City Elizabeth St Stop E" 14:06 catch bus 39 to stop 350 "52 New Town Rd" 14:17 walk 35m to destination 14:18 arrive From 00014979@csse.uwa.edu.au Fri Sep 18 05:51:30 2015 Date: Fri Sep 18 05:51:30 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.82.92 Subject: Abort trap 6 From: "Christopher McDonald" X-smilie: none X-img: none Are you using any dynamic allocation (malloc, free) in your program, rather than just a fixed number of fixed sized arrays? abort() is usually called by C's library functions if they detect an internal error, sometimes after being called incorrectly or by incorrectly using or modifying their return result (if a pointer). For example malloc() will call abort() if its internal structures are damaged by a heap overflow. From khooe03@csse.uwa.edu.au Fri Sep 18 07:46:18 2015 Date: Fri Sep 18 07:46:18 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.135 Subject: Minimising walking distance From: "Elliot Khoo" <10421053@student.uwa.edu.au> X-smilie: none X-img: none Hi Chris, I was testing my output against yours, and sometimes i get slightly different answers. I try to minimise walking distance where possible when getting on the origin stop. I think there are also some trips where the journey is different but the arrival time is the same. I was wondering how does the automatic marker work, do I need to find the exact same trips as you even if the journey time is exactly the same? Thanks Elliot From coopea04@csse.uwa.edu.au Fri Sep 18 07:46:47 2015 Date: Fri Sep 18 07:46:47 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.140 Subject: Someone had to ask it From: "Adrian Cooper" <20786307@student.uwa.edu.au> X-smilie: none X-img: none For those of us who cannot debug the code well enough to get a proper answer, what portion of the marks is on the code working properly and what portion is on explaining with comments how the code is meant to work and the reasoning behind it? From liaoj02@csse.uwa.edu.au Fri Sep 18 08:15:57 2015 Date: Fri Sep 18 08:15:57 2015 To: help2002@csse.uwa.edu.au Received: from 43.252.114.182 Subject: cssubmit no such file message From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Archive contains: /home/www/cssubmit/unrar.sh: line 3: /usr/bin/unrar: No such file or directory /home/www/cssubmit/unrar.sh: line 3: exec: /usr/bin/unrar: cannot execute: No such file or directory Did I successfully submit? Green tick though. From 00014979@csse.uwa.edu.au Fri Sep 18 08:22:54 2015 Date: Fri Sep 18 08:22:54 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.82.92 Subject: cssubmit no such file message From: "Christopher McDonald" X-smilie: none X-img: none Why submit a RAR archive when the project asks for a single C file? From nelsoj07@csse.uwa.edu.au Fri Sep 18 08:23:19 2015 Date: Fri Sep 18 08:23:19 2015 To: help2002@csse.uwa.edu.au Received: from 60.230.195.113 Subject: Different public transport data sets From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none If we have accounted for this, by scanning the first line to set the fields that we need to get, is this fine? From coopea04@csse.uwa.edu.au Fri Sep 18 08:31:56 2015 Date: Fri Sep 18 08:31:56 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.140 Subject: Different public transport data sets From: "Adrian Cooper" <20786307@student.uwa.edu.au> X-smilie: none X-img: none How did you get your display picture to be Kermit the Frog From liaoj02@csse.uwa.edu.au Fri Sep 18 08:35:18 2015 Date: Fri Sep 18 08:35:18 2015 To: help2002@csse.uwa.edu.au Received: from 43.252.114.182 Subject: cssubmit no such file message From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > Why submit a RAR archive when the project asks for a single C file? I got one header file. Is that fine? From 00014979@csse.uwa.edu.au Fri Sep 18 08:36:52 2015 Date: Fri Sep 18 08:36:52 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.82.92 Subject: cssubmit no such file message From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > I got one header file. Is that fine? No. Please follow the project's directions, else marking becomes difficult. From coopea04@csse.uwa.edu.au Fri Sep 18 08:48:40 2015 Date: Fri Sep 18 08:48:40 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.140 Subject: Is a / assumed at the end of the directory? From: "Adrian Cooper" <20786307@student.uwa.edu.au> X-smilie: none X-img: none For the input parameter, can we assume there is a slash at the end of the directory of the files to be read? Or will there not be a slash, and it has to be added to the string of the file to open From 00014979@csse.uwa.edu.au Fri Sep 18 08:50:39 2015 Date: Fri Sep 18 08:50:39 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.82.92 Subject: Minimising walking distance From: "Christopher McDonald" X-smilie: none X-img: none As discussed elsewhere, the marker generates multiple solutions that each have the same total time, so you'll only need to find one of those. There's no *single* solution because it depends on the order in which your projects finds solutions. From 00014979@csse.uwa.edu.au Fri Sep 18 08:53:16 2015 Date: Fri Sep 18 08:53:16 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.82.92 Subject: Someone had to ask it From: "Christopher McDonald" X-smilie: none X-img: none "Adrian Cooper" <20786307@student.uwa.edu.au> wrote: > For those of us who cannot debug the code well enough to get a proper answer, what portion > of the marks is on the code working properly and what portion is on explaining with > comments how the code is meant to work and the reasoning behind it? Half marks come from automated marking, half from visual inspection. If possible, try to have your solution produce/check some things, rather than it always crashing because of the same type of problem. Those reading your code will read the comments, too, though they're not contributing as much to your project as would be working code. From 00014979@csse.uwa.edu.au Fri Sep 18 08:54:15 2015 Date: Fri Sep 18 08:54:15 2015 Edit: Fri Sep 18 08:54:51 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.82.92 Subject: Is a / assumed at the end of the directory? From: "Christopher McDonald" X-smilie: none X-img: none Do not assume that there will be a slash there. Notice how none of the examples being discussed have had that slash. From 00014979@csse.uwa.edu.au Fri Sep 18 09:13:58 2015 Date: Fri Sep 18 09:13:58 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.82.92 Subject: Different public transport data sets From: "Christopher McDonald" X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > If we have accounted for this, by scanning the first line to set the fields that we need to get, > is this fine? Yes (as long it doesn't accidentally break something else!) Have you successfully tried some other datasets? From nelsoj07@csse.uwa.edu.au Fri Sep 18 09:18:14 2015 Date: Fri Sep 18 09:18:14 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.183.223 Subject: Different public transport data sets From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none After seeing this post I tried Drwin and Hobart, and it works conpketely* for Darwin and with some bugs like not showing a route name but planning out a trip anyway for Hobart. It may be because the trams don't have route names or other inconsistencies I haven't found yet, but it still works exactly the same for Transperth data! *as far as I can tell From hon06@csse.uwa.edu.au Fri Sep 18 09:30:48 2015 Date: Fri Sep 18 09:30:48 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.126 Subject: maximum id length? From: "Nathan Ho" <21506898@student.uwa.edu.au> X-smilie: none X-img: none Is there a suggested/suitable maximum we could say stop_id's, trip_ids etc. are? Thanks. From 00014979@csse.uwa.edu.au Fri Sep 18 10:27:29 2015 Date: Fri Sep 18 10:27:29 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: maximum id length? From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Is there a suggested/suitable maximum we could say stop_id's, trip_ids etc. are? Thanks. Please see the Clarifications page (if you're asking about their maximum string length). From nelsoj07@csse.uwa.edu.au Fri Sep 18 10:29:24 2015 Date: Fri Sep 18 10:29:24 2015 Edit: Fri Sep 18 10:30:10 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.235.222 Subject: 14:00 no routes available error message From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Hey Chris, Sorry if this has been asked or answered elsewhere but I couldn't see it. If we can't find a route, and LEAVEHOME is say Wed 09:00, do we return the error message: 14:00 not possible or 09:00 not possible Is the time still the LEAVEHOME time? It's sounding like a silly question but I just wasn't sure! Also to clarify the times are meant to be printed in 24 hour time? Thanks! From 00014979@csse.uwa.edu.au Fri Sep 18 10:31:06 2015 Date: Fri Sep 18 10:31:06 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: 14:00 no routes available error message From: "Christopher McDonald" X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > 09:00 not possible This. > Is the time still the LEAVEHOME time? It's sounding like a silly question but I just > wasn't sure! Also to clarify the times are meant to be printed in 24 hour time? Yes. From nelsoj07@csse.uwa.edu.au Fri Sep 18 10:36:33 2015 Date: Fri Sep 18 10:36:33 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.235.222 Subject: 14:00 no routes available error message From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Thanks :) From graven01@csse.uwa.edu.au Fri Sep 18 11:44:45 2015 Date: Fri Sep 18 11:44:45 2015 Edit: Fri Sep 18 12:22:32 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Strict deadline From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none i was looking around but couldn't find the late submission policy, i handed it in a few minutes late, and was wondering 1. how strict is the deadline? 2. since my project is extremely close (just needed to convert the time back to a string and print it out to the user) since the auto marker would give a 0 for it, would it be inspected and marked accordingly 3.are the bonus marks able to "UNDO" late penalty marks? From 00014979@csse.uwa.edu.au Fri Sep 18 12:20:02 2015 Date: Fri Sep 18 12:20:02 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Strict deadline From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > i just found a few bugs that i didn't expect if i'm an hour late do i lose 20%? Submit one version (now), and another (with a different name) with your changes, and we'll see how much the time has benefited you. From graven01@csse.uwa.edu.au Fri Sep 18 12:23:36 2015 Date: Fri Sep 18 12:23:36 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Strict deadline From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none ok will do, thanks From fetzee01@csse.uwa.edu.au Fri Sep 18 14:52:32 2015 Date: Fri Sep 18 14:52:32 2015 To: help2002@csse.uwa.edu.au Received: from 175.38.164.221 Subject: visual inspection: tab sizes / tab stop? From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none Hello Chris, We submitted our program, which included tab characters (e.g. comments, declarations), formatted for a tabstop of 8 (default gvim/macvim profile setting on the lab machines) The result is if you change the tabstop the formatting isn't as consistent.. Can we assume that the programs are marked with a tabstop of 8? or at least know if it is a big issue or not. Thank you . From 00014979@csse.uwa.edu.au Fri Sep 18 14:57:10 2015 Date: Fri Sep 18 14:57:10 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: visual inspection: tab sizes / tab stop? From: "Christopher McDonald" X-smilie: none X-img: none Not a big issue; we can identify consistent+irregular tabs :-) Somewhere along the way, the '2002 cohort this year appears to have been seriously burnt by some bad experience with marking in a previous unit - many, many students posting and emailing about their submissions being 2 minutes late, ...., and even their tabstops. Would love to identify where and why, or are we really perceived as being that evil?! From abusha02@csse.uwa.edu.au Fri Sep 18 16:12:25 2015 Date: Fri Sep 18 16:12:25 2015 To: help2002@csse.uwa.edu.au Received: from 220.253.171.201 Subject: visual inspection: tab sizes / tab stop? From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none Most students that took 2200 last semester are taking this unit right now....that might have something to do with it, since the project in that unit was handled quite poorly. The requirements were changed several times throughout its duration, and the marking was inconsistent with both the lecturers stated requirements, as well the marking criteria (published along with the project description). Additionally, I know of several instances where students were marked down for things that were correct, or because a marker didn't quite understand what they were doing. I'm assuming students coming from that unit last semester are trying to play it as safe as possible, and that might be why there are so many requests for clarification regarding minor technicalities. From abusha02@csse.uwa.edu.au Fri Sep 18 16:44:25 2015 Date: Fri Sep 18 16:44:25 2015 Edit: Fri Sep 18 16:44:53 2015 To: help2002@csse.uwa.edu.au Received: from 220.253.171.201 Subject: Different public transport data sets From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none To the guy asking about changing display pictures: https://secure.csse.uwa.edu.au/run/help2002?p=np&a=523&all=y4 From newmal01@csse.uwa.edu.au Wed Sep 23 12:33:36 2015 Date: Wed Sep 23 12:33:36 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.118.140 Subject: make file.txt From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none how can you make your own txt file on the mac computers? also can you read files regardless of what program data has been documented in? for example would the following work? FILE *file file=fopen(file.docx,"r"); From 00014979@csse.uwa.edu.au Wed Sep 23 14:10:34 2015 Date: Wed Sep 23 14:10:34 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: make file.txt From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > how can you make your own txt file on the mac computers? At the shell prompt, you can trivially execute: prompt> echo this is some text > file.txt or you can use an editor, such as vim, to help type some text into a new file. However the filename's extension provides no guarantee of what's really in the file: prompt> echo this is not a Word document > file.docx > also can you read files regardless of what program data has been documented in? > for example would the following work? > > FILE *file > file=fopen(file.docx,"r"); If the file's name was in double quotes, then the above code would *open* the named file, and subsequent calls to fgets() or fread() could be used to read in the contents. So, yes. However, even if a file's name indicates that it's a Word document, and even if the file was created using the Word application, that doesn't mean that your program will be able to *understand* the contents of the file simply by reading it. From newmal01@csse.uwa.edu.au Wed Sep 23 17:11:25 2015 Date: Wed Sep 23 17:11:25 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.118.140 Subject: make file.txt From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none how can you ensure that the program can correctly read the contents of a file? From lis63@csse.uwa.edu.au Wed Sep 23 22:14:50 2015 Date: Wed Sep 23 22:14:50 2015 Edit: Wed Sep 23 22:21:49 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.185.96 Subject: questions about malloc() function From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none I test the Monday lecture experiment(the one with 2000 GBs) with my laptop. However, it works on ubuntu but doesn't work on windows(vs 2013). On windows, I only got 1 GB and the program ended. (my laptop has 4 GB memory and less than 2 GB free) Here is my code: #include #include #include #define GB (1<<30) int main(){ char *p; for (int i = 1;; ++i){ p = (char*)malloc(GB); if (p == NULL) break; //memset(p, 'a', GB); printf("%iGB\n", i); } return 0; } So does it mean the results of malloc() depends on complilers? Besides,since malloc() function can allocate more than 2000 GBs, I cannot understand the meaning of writing code like " if(huge_array == NULL) exit(1); " to check if malloc() runs successfully. The checking code seems useless. From 00014979@csse.uwa.edu.au Thu Sep 24 07:13:39 2015 Date: Thu Sep 24 07:13:39 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.82.92 Subject: make file.txt From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > how can you ensure that the program can correctly read the contents of a file? To clarify - a program can successfully *read* the contents of a file without *understanding* the format or representation of the file's contents. Consider the files used in the 1st project. Any program can *read* the files' contents, perhaps byte-by-byte or line-by-line; possible to read the file without understand what is being read. But because any file can potentially have a different format, the program reading it has to know that format to make sense of (again, the project) the fact that the data was line- oriented, that each line contained a number of fields, that the fields were separated by commas, what the third field of the line meant.... So because each program needs to *know* the format of the data in the file, and that understanding needs to be encoded in the reading, manipulation/calculation, and (likely) writing of that data according to that format (particularly so that other programs can read in the results), that knowledge typically has to come from documentation of the format, as with the 1st project (or a good guess if it's human-readable). ---- When considering advanced uses of databases, we often use a *2nd* file named a data- dictionary, which describes the format of the main data file (and then we have to know the format of the data-dictionary file...) From 00014979@csse.uwa.edu.au Thu Sep 24 07:50:57 2015 Date: Thu Sep 24 07:50:57 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.82.92 Subject: questions about malloc() function From: "Christopher McDonald" X-smilie: none X-img: none "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > So does it mean the results of malloc() depends on complilers? No, not on compilers or even the language's standard library, but from the OS's willingness or ability to provide the memory you request. malloc()'s responsibility is to simply accept the request (size) and either return a pointer to (at least) that much space, or to report failure. (Typically) the compiler doesn't know what malloc() doesl it's just another function, like sqrt(), found in the standard library. But your OS may not be able to provide the requested memory - it may genuinely run out of available memory, or choose to limit the amount of memory provided to any single process (or user) to provide fairness for all other processes or users. And if the OS places some fixed limit on that, then your process may not get the requested memory even if, at the time, there is free memory available. > Besides,since malloc() function can allocate more than 2000 GBs, I cannot understand > the meaning of writing code like " if(huge_array == NULL) exit(1); " to check if > malloc() runs successfully. The checking code seems useless. Why is the checking useless? In your very own example, the call to malloc() was unsuccessful, and your program wanted to know about that. From lis63@csse.uwa.edu.au Thu Sep 24 09:17:41 2015 Date: Thu Sep 24 09:17:41 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.185.96 Subject: questions about malloc() function From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none Thank you! I tested it with gcc on windows today. As you say, the output depends on operating system rather than complier. From 00014979@csse.uwa.edu.au Thu Sep 24 11:00:35 2015 Date: Thu Sep 24 11:00:35 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Tutorial 7, for Friday 25th, now available From: "Christopher McDonald" X-smilie: none X-img: none X-announcefor: 36h From: http://teaching.csse.uwa.edu.au/units/CITS2002/tutorials/tutorial7.php From tans121@csse.uwa.edu.au Thu Sep 24 18:16:15 2015 Date: Thu Sep 24 18:16:15 2015 To: help2002@csse.uwa.edu.au Received: from 58.111.105.54 Subject: lab5 Q4 From: "Shao-Ming Tan" <20920822@student.uwa.edu.au> X-smilie: none X-img: none Hi, The answer for lab5 Q4 is not working for me, not sure if it's my computer... I'm getting this as the error message but not sure why? test.c:11:18: error: ordered comparison between pointer and integer ('int' and 'int *') [-Werror] if(*maxp < *values) ~~~~~ ^ ~~~~~~~ test.c:13:18: error: incompatible pointer types assigning to 'int *' from 'int **'; dereference with * [-Werror,-Wincompatible-pointer-types] maxp = values; ^ ~~~~~~ * The code makes sense to me but I don't understand why it's giving me an error. Also, I'm not sure what is the input into the function, it says int *values[] but I've tried passing an array and a pointer to the array as parameters(after editing the function with **values) to the function but still no luck. From 00014979@csse.uwa.edu.au Thu Sep 24 19:46:43 2015 Date: Thu Sep 24 19:46:43 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.82.92 Subject: lab5 Q4 From: "Christopher McDonald" X-smilie: embarrassed.png X-img: none Oops, sorry about that - the solution didn't even match the prototype! Corrected now. From newmal01@csse.uwa.edu.au Fri Sep 25 18:12:16 2015 Date: Fri Sep 25 18:12:16 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.149.225 Subject: Project 1 marks From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none Hi I was just wondering when the marks for project one will be released? From 00014979@csse.uwa.edu.au Sat Sep 26 05:56:19 2015 Date: Sat Sep 26 05:56:19 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.82.92 Subject: Project 1 marks From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hi I was just wondering when the marks for project one will be released? In at least another 10 days. From tans121@csse.uwa.edu.au Sun Sep 27 01:47:39 2015 Date: Sun Sep 27 01:47:39 2015 To: help2002@csse.uwa.edu.au Received: from 58.111.105.54 Subject: Tutorial edits question From: "Shao-Ming Tan" <20920822@student.uwa.edu.au> X-smilie: none X-img: none So just having a question on the tutorial edits and wondering if this is right? char **viable_home_stopid is a pointer to a vector of pointers to strings/characters viable_home_stopid points to the first element of this vector or viable_home_stopid[0] which is an 8byte pointer to the address of the first bus stop (assuming it has been entered)? viable_home_stopid = realloc(viable_home_stopid, (n_viable_homes+1)*sizeof*viable_home_stopid[0]) This line creates memory for each pointer in the vector of strings? So if there were three strings in the vector (i.e. three bus stops) the size of the pointer "array/vector" (viable_home_stopid) will be 8*3 = 24 bytes? viable_home_stopid[n_viable_homes+1] = strdup(fields[F_STOPS_ID]; The memory allocation for the string is done by strdup and the memory allocated by strdup has nothing to do with memory allocation with the pointer of viable_home_stopid? From graven01@csse.uwa.edu.au Sun Sep 27 08:04:09 2015 Date: Sun Sep 27 08:04:09 2015 Edit: Sun Sep 27 08:06:04 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: [Project 1] - how would Transperth do it (fast)? From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none [I've given this interesting question a new title, in the hope that a few more students will see it and contribute ideas - Chris] just out of curiosity, How would a service like project 1 be implemented on a web site, what kind of resources and obstacles would there be considering the average run time is ~7 seconds and that if on a transperth website it could be getting multiple (hundreds?) of queries at a time. From 00014979@csse.uwa.edu.au Tue Sep 29 07:41:48 2015 Date: Tue Sep 29 07:41:48 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.82.92 Subject: Your feedback on the 1st project From: "Christopher McDonald" X-smilie: none X-img: none X-announcefor: 10d Your feedback on the 1st project is now available, via http://teaching.csse.uwa.edu.au/units/CITS2002/projects/project1-feedback/ As well as the simple histograms, please have a look through the comments of your peers, and the replies I've made in blue to some of them. If you're a student who felt that the project was far too difficult, or one who felt it far too easy, you will see the (traditional) diversity of opinions and satisfaction is quite notable. Of course, please follow-up with any additional comments or questions via email, or on help2002. From 00014979@csse.uwa.edu.au Sat Oct 3 08:13:38 2015 Date: Sat Oct 3 08:13:38 2015 To: help2002@csse.uwa.edu.au Received: from 27.54.43.67 Subject: Tutorial edits question From: "Christopher McDonald" X-smilie: none X-img: none > So just having a question on the tutorial edits and wondering if this is right? Your thinking is correct, though would be broader if you didn't think about the size required to hold various things. For example, don't focus on a pointer being 8 bytes of storage, as it won't be 8 bytes on all platforms - just think of it being enough memory (at least enough memory) to store a pointer. If you find the logic buried too deeply inside the project example, consider something simpler, holding a vector of strings. - initially the vector doesn't exist, so we start with: char **vector = NULL; int length = 0; - then, each time we grow the vector, we request more space with realloc(), initialise that newly allocated space, and remember that the vector is now one longer: vector = realloc(vector, (length+1) * sizeof(vector[0])); vector[length] = its_initial_value; ++length; > viable_home_stopid[n_viable_homes+1] = strdup(fields[F_STOPS_ID]; There should be no +1 in the above. ----- To ensure that you understand it, try Q4 on Labsheet 6, which asks you to read a whole text file into memory, saving each line as you go. From newmal01@csse.uwa.edu.au Sun Oct 4 14:15:31 2015 Date: Sun Oct 4 14:15:31 2015 To: help2002@csse.uwa.edu.au Received: from 120.145.160.140 Subject: Past results of project 1 From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none I was just wondering what the average mark for past project 1 results as well as the differentiation between results? From 00014979@csse.uwa.edu.au Sun Oct 4 16:54:07 2015 Date: Sun Oct 4 16:54:07 2015 To: help2002@csse.uwa.edu.au Received: from 27.54.43.67 Subject: Past results of project 1 From: "Christopher McDonald" X-smilie: none X-img: e3b6fbcd1553aee95419052c43e55da0.png ANONYMOUS wrote: > I was just wondering what the average mark for past project 1 results as well as the > differentiation between results? By "just wondering" I suspect you may be unnecessarily worrying. There's no secrets, but it's very difficult to compare results between years, so I'm unsure how you'll interpret the details. Last year was the first time CITS2002 was offered as a 2nd year unit, and many of the 141 students (at start) indicated that it was their first programming unit, with many taking CITS2140 concurrently (most Computer Science and/or Data Science students had taken the level-1 unit in 2013, so it was an unusual transition). Of the 118 students submitting the 1st project, 93 passed it and the project average (including 16 students who did not submit the project, receiving 0/40) was 22.9/40, stdev 11.5. You'll also note that a good number of students received full marks. And, in anticipation of a future question, here's the students' feedback from 2014, keeping in mind that the project was different, but also released after Week-5: http://teaching.csse.uwa.edu.au/units/CITS2002/projects/project1-feedback/2014/ From mcfald01@csse.uwa.edu.au Mon Oct 5 09:29:56 2015 Date: Mon Oct 5 09:29:56 2015 Edit: Mon Oct 5 09:35:39 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.172.71 Subject: Exam revision From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none My question is about the level of detail that will go into theory questions in the exam. In the lectures I've noticed that Chris tends to abstract his explanations or present them in a wildly different perspective to the notes, perhaps exposing another layer or two of depth to the intricacies of compilers and operating systems. Are we expected to know or study those intricate details for the exam or would a broader (perhaps more practical) understanding be more suitable? On a slightly off topic note, personally I love this style of lecture so by no means am I suggesting that it should change, I just wanted clarification. I can tell that Chris is very passionate about the topic and has so far been an amazing coordinator. (on another side note, it feels weird to address someone in third person since it's a public board, yet he's/you're probably the direct recipient.) Cheers From graven01@csse.uwa.edu.au Mon Oct 5 10:16:46 2015 Date: Mon Oct 5 10:16:46 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Exam revision From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none "Daniel Mcfall" <21312007@student.uwa.edu.au> wrote: > Chris is very passionate about the topic and has so far been an amazing coordinator. imo the lecturers of other units (cits in particular) need to take a leaf out of Chris's book, mostly seem they don't want to be there (perhaps they don't) i really appreciate his passion for actual teaching and his interactivity with a large group of students. Thank you. From lopasb03@csse.uwa.edu.au Mon Oct 5 14:54:32 2015 Date: Mon Oct 5 14:54:32 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.57.29 Subject: Exam revision From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: verycool.png X-img: none There is no doubt that Chris is a great lecturer, however if I was youse I would concentrate on the lecture notes. ie, they can't examine you on stuff they havn't asked you to learn, study, etc... From lopasb03@csse.uwa.edu.au Tue Oct 6 16:54:31 2015 Date: Tue Oct 6 16:54:31 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Project 1 marks From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > Hi I was just wondering when the marks for project one will be released? > > In at least another 10 days. How much longer now? From lis63@csse.uwa.edu.au Tue Oct 6 20:27:11 2015 Date: Tue Oct 6 20:27:11 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.185.96 Subject: a question on lab 6 From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none In the second task of lab 06, in the step b, it says "or to count the input "arriving" ", but I don't know what the "arriving" mean. Does it represent any sentence, which means we need to count the number of words in a sentence? From 00014979@csse.uwa.edu.au Wed Oct 7 13:46:48 2015 Date: Wed Oct 7 13:46:48 2015 To: help2002@csse.uwa.edu.au Received: from 27.54.43.67 Subject: a question on lab 6 From: "Christopher McDonald" X-smilie: none X-img: none "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > In the second task of lab 06, in the step b, it says "or to count the input > "arriving" ", but I don't know what the "arriving" mean. Does it represent any > sentence, which means we need to count the number of words in a sentence? Sorry for any confusion. I've just used the word "arriving" to imply that the data to be read via the file pointer may be dynamically generated, or being accessed across a network - hence I'm just causally saying that the data "arrives", rather than it already being their if being read from a file. The beauty of the OS's I/O system is that one a file pointer has been opened and passed to a function, the function can just read data using the file pointer, without caring if the data is coming from a file, the keyword, a pipe, or even a network connection. There'll be no need to handle any special cases in this lab exercise - just read from the file pointer as in earlier examples. From abusha02@csse.uwa.edu.au Wed Oct 7 13:53:31 2015 Date: Wed Oct 7 13:53:31 2015 To: help2002@csse.uwa.edu.au Received: from 106.68.31.72 Subject: Project 1 marks From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none I've come from 10 days in the future, and the projects had been released by then. Also, I think you might have failed. From 00014979@csse.uwa.edu.au Wed Oct 7 14:18:26 2015 Date: Wed Oct 7 14:18:26 2015 To: help2002@csse.uwa.edu.au Received: from 27.54.43.67 Subject: Exam revision From: "Christopher McDonald" X-smilie: none X-img: none "Daniel Mcfall" <21312007@student.uwa.edu.au> wrote: > My question is about the level of detail that will go into theory questions in the > exam. > > In the lectures I've noticed that Chris tends to abstract his explanations or present > them in a wildly different perspective to the notes, perhaps exposing another layer or > two of depth to the intricacies of compilers and operating systems. Are we expected to > know or study those intricate details for the exam or would a broader (perhaps more > practical) understanding be more suitable? Hi Daniel, A good (and important) question, though a bit difficult to provide a one-size-fits-all answer. The Unit Schedule defines the topics covered in the unit, and the lecture slides fill out those topics a bit. But lectures with nothing more than reading the slides are, as we all know, quite boring, so I try to further fill out the material with some small examples that, despite OSs being large, intricate, beasts, show we can still see seem evidence of their internal implementations and policies. But, no, you're certainly not expected to be able to repeat the (sometimes failing!) examples that I show in lectures, nor have all the background knowledge. However, keeping in mind that 2-3 of our lectures *identify* (notice that I'm not saying "teach*) the material from about a chapter from a traditional textbook, then you do have more work to do than just understanding the point that a lecture was trying to get across. I'd also hope that, having read a textbook's chapter, that you'd have a little curiosity left to say "hmmm, I wonder if I can see that happening on *my* OS or laptop?" It also works the other way, too (though this may not apply to you) - once you become a more accomplished user of your own OS and equipment, you can build a healthy technical curiosity of how it works, and return to textbooks (rather than just the OS documentation) to better understand why things have been designed, or appear, the way they are. From graven01@csse.uwa.edu.au Wed Oct 7 14:36:45 2015 Date: Wed Oct 7 14:36:45 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Project 1 marks From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none can i have next weeks lottery numbers since i failed? From 00014979@csse.uwa.edu.au Wed Oct 7 14:36:54 2015 Date: Wed Oct 7 14:36:54 2015 To: help2002@csse.uwa.edu.au Received: from 27.54.43.67 Subject: Exam revision From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > There is no doubt that Chris is a great lecturer, however if I was youse I would concentrate on the > lecture notes. ie, they can't examine you on stuff they havn't asked you to learn, study, etc... (thanks for the kind comments) but try not to get caught in the (too) common belief that it's all about the lecture notes - some wrongly believe this to the point of just rote learning lecture notes, and reading nothing else. The Unit Schedule defines the topics covered (let's call those the topics that could be examined), and the lecture notes fill out the topic descriptions with a bit of detail and some examples. But consider an example (which I've just made up!) regarding material recently covered; imagine this as an exam question: Q: Two hardware-based approaches to memory management are paging and segmentation. Which of these could provide a greater benefit than the other when executing C99 programs, and why? I'd think about it a lot more before actually setting it as an exam question (how hard it is, how much I'd expect you to write, etc), but you'll notice that it's not a question whose answer you'll find in the lecture notes, and probably not in standard/recommended textbooks, either. It's not a question that I'd expect you to instantly know the answer to, when you first read it during the exam, but one that I'd expect you to be able to answer after 5 minutes of thinking about parts of our unit and how they fit together. From jennib03@csse.uwa.edu.au Wed Oct 7 19:49:49 2015 Date: Wed Oct 7 19:49:49 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.237.170 Subject: Exam revision From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > (thanks for the kind comments) > but try not to get caught in the (too) common belief that it's all about the lecture notes - some wrongly > believe this to the point of just rote learning lecture notes, and reading nothing else. Honestly, I don't believe this to be fair. There are no guarantees that everyone will have the same opportunities to learn everything that may or may not be expected to have been covered by an unknown textbook. I know we are given a list of recommended textbooks, but different books will invariably cover different topics, or different scopes of the same topic. And again, they are just "recommended"... How do we know if we are getting the right information if we use a different, but similar textbook? I believe that when it comes to examinations, we should only be examined on information we have all been provided fair and equal opportunity to learn. And saying we have all been provided the opportunity to go and read all of the recommended texts isn't fair either, as it is highly unlikely that we have the time to consume and comprehend that much information. Whilst a lot can be said about the inadequacies of what is effectively rote learning when it comes to lecture notes and prescribed textbooks, a lot can also be said for ensuring everyone is on the same page by having prescribed textbooks (or even provided set chapters from various textbooks as other units do), and access to the same lecture notes (which obviously we do, but they are very broad in scope). Maybe a unit reader would be appropriate rather than a set textbook, as I know you said something along the lines that you don't believe any existing textbook or combination of textbooks effectively covers everything you think should be covered. I love your lecturing style Chris, it reminds me of my dad personally (he lectured at TAFE up north for a *very* long time in advanced IT courses, and was well liked and apparently taught effectively as well), but the timing of the unit (i.e., incredibly short time provided for the first project as shown by feedback) and the ambiguousness in terms of what *needs* to be learned for examination purposes, versus what *could* be learned for practical purposes is really irritating. I can't wait to be coming back and revising my notes from your lectures to apply the content to real world problems that I know I'll have. And I do like that you provide opportunity for self learning. But at the same time, we still want to do well in our exams, and with our grades - and we only have so much time to study. It would be great to have a list of specific topics that you feel are *very* important and therefore will be examined so we can make notes of the other stuff, but not be worried about focusing on the wrong content come exam time. I.e., more unambiguous guided self learning? From jennib03@csse.uwa.edu.au Wed Oct 7 20:08:05 2015 Date: Wed Oct 7 20:08:05 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.237.170 Subject: [Project 1] - how would Transperth do it (fast)? From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > just out of curiosity, How would a service like project 1 be implemented on a web > site, what kind of resources and obstacles would there be considering the average run > time is ~7 seconds and that if on a transperth website it could be getting multiple > (hundreds?) of queries at a time. I can't say for certain, but typically it would be implemented as an (Application Programming Interface) API first of all, allowing various services to access the information. Personally, I probably wouldn't write the API in C, I'd probably use something like Node.js, and maybe use C for anything that needs to be optimised. Also, there were some projects that were getting results in under a second, so a live solution would probably be highly optimised. As an example, you might find most of the functions required in the project problem would be needed by other API calls as well, so they would be broken out into their own routes. For example, you might need to have: GET https://transperth.wa.gov.au/api/stops.json/?lat=xx.xxx&lng=xx.xxx&radius=1000 which could return a JSON formatted list of stops within 1000m of a geo position. Then you might also implement: GET https://transperth.wa.gov.au/api/trips.json/?stopid=xxxxx&leaving=201510072006 and eventually once you have all of the parts working, you might create: GET https://transperth.wa.gov.au/api/journey.json/?origin=....&destination=...&time=... which could return the journey in a JSON output, allowing whatever program is calling it to interpret it as needed... Then for example, you have different clients that can all use the API. So you can text a stop ID to 136213, and the service could use the API to get the next available buses and text it back to the user. Or the Transperth app could use the same API as the website, they'd just display the information differently. You'll probably also find that the data would be stored in a database, and then caching can be done to help optimise further... I've probably gotten some of the specifics (to the project) wrong, but hopefully that gives you an idea of how it might work. From lis63@csse.uwa.edu.au Wed Oct 7 21:01:50 2015 Date: Wed Oct 7 21:01:50 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.221.171 Subject: a question on lab 6 From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > > > In the second task of lab 06, in the step b, it says "or to count the input > > "arriving" ", but I don't know what the "arriving" mean. Does it represent any > > sentence, which means we need to count the number of words in a sentence? > > Sorry for any confusion. > I've just used the word "arriving" to imply that the data to be read via the file pointer > may be dynamically generated, or being accessed across a network - hence I'm just causally > saying that the data "arrives", rather than it already being their if being read from a > file. > > The beauty of the OS's I/O system is that one a file pointer has been opened and passed to > a function, the function can just read data using the file pointer, without caring if the > data is coming from a file, the keyword, a pipe, or even a network connection. > > There'll be no need to handle any special cases in this lab exercise - just read from the > file pointer as in earlier examples. Thank you. I find that the manual says if users input no file name or the file name is '-' the program should read standard input. And I think that's what the step b asks us to do. Is it right? From 00014979@csse.uwa.edu.au Thu Oct 8 11:50:59 2015 Date: Thu Oct 8 11:50:59 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: a question on lab 6 From: "Christopher McDonald" X-smilie: none X-img: none "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > I find that the manual says if users input no file name or the file name is '-' the program > should read standard input. And I think that's what the step b asks us to do. Is it right? That's not what the lab sheet is asking for, though it does raising an interesting point. Yes, some applications (though not all) will support/recognize that if their input filename is the string "-", that they should read their input from stdin (and in some programs also write their output to stdout). There's nothing specific within either C or Unix-based operating systems to support this, it's just a convention, so each program has to provide its own code: if(strcmp(argv[1], "-") == 0) { process(stdin); } Of note, Windows-based systems *do* have OS-level support for some special filenames, which are opened or created automatically if you (even accidentally) use special patterns as filenames: http://blogs.msdn.com/b/oldnewthing/archive/2003/10/22/55388.aspx https://msdn.microsoft.com/en-us/library/aa365247.aspx ------ Personally I find these 'special' filenames a source of confusion and potential bugs, but they're (still) there because Windows-based systems (yes, still in Windows-10) provide so much backwards compatibility with older systems. Unix-based systems also have a lot of backwards compatibility with older Unix systems, too, but it's more along the lines of "there still are no special filenames to worry about". From newmal01@csse.uwa.edu.au Thu Oct 8 14:30:33 2015 Date: Thu Oct 8 14:30:33 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.95.192 Subject: Project 1 marks From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none How long now? From 00014979@csse.uwa.edu.au Thu Oct 8 14:46:09 2015 Date: Thu Oct 8 14:46:09 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Project 1 marks From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > How long now? I cannot state to the accuracy that you are demanding. Won't be today, and unlikely to be completed by tomorrow, either. (ahhh, the power of anonymous posting!) From graven01@csse.uwa.edu.au Thu Oct 8 15:31:14 2015 Date: Thu Oct 8 15:31:14 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Project 1 marks From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none Cool see you Saturday :p From 00014979@csse.uwa.edu.au Thu Oct 8 16:27:19 2015 Date: Thu Oct 8 16:27:19 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Tutorial 8 is now available From: "Christopher McDonald" X-smilie: none X-img: none X-announcefor: 1d Tutorial 8, from: http://teaching.csse.uwa.edu.au/units/CITS2002/tutorials/tutorial8.php From lis63@csse.uwa.edu.au Thu Oct 8 23:01:16 2015 Date: Thu Oct 8 23:01:16 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.221.171 Subject: a warning on lab06 task 05 "implicit declaration of function `strdup'" From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none Hi, When I use strdup() in my code, I couldn't compile my code due to the warning: "implicit declaration of function `strdup'". Now I add "extern char *strdup(const char *s);" and the problem is solved. I just wonder why it happened. I have included string.h in my code and google tells me strdup is declared in string.h. Is there any other way to declare the function? By the way, I code on ubuntu. Not sure if it will happen on OSX. From 00014979@csse.uwa.edu.au Fri Oct 9 05:42:18 2015 Date: Fri Oct 9 05:42:18 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: a warning on lab06 task 05 "implicit declaration of function `strdup'" From: "Christopher McDonald" X-smilie: none X-img: none "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > Hi, When I use strdup() in my code, I couldn't compile my code due to the warning: > > "implicit declaration of function `strdup'". > > > Now I add "extern char *strdup(const char *s);" and the problem is solved. > > I just wonder why it happened. I have included string.h in my code and google tells > me strdup is declared in string.h. > > Is there any other way to declare the function? > > By the way, I code on ubuntu. Not sure if it will happen on OSX. strdup() is not a function defined by the C99 standard, so it will not be 'automatically' available by just requesting C99 via your compiler. In the case of Linux, yes, the strdup() function's prototype appears in the header file /usr/include/string.h but it is wrapped/hidden by a preprocessor conditional: #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 /* Duplicate S, returning an identical malloc'd string. */ extern char *strdup (__const char *__s); #endif which states that if any of those other standard's tokens are defined, such as __USE_SVID, then the prototype becomes visible to your code. In the case of OS-X, its /usr/include/string.h wraps the strdup() prototype with preprocessor conditions requiring certain versions of POSIX, which is predefined by Apple's C compiler when you request C99: #if __DARWIN_C_LEVEL >= 200112L char *strdup(const char *); ...... #endif /* __DARWIN_C_LEVEL >= 200112L */ From graven01@csse.uwa.edu.au Fri Oct 9 07:00:09 2015 Date: Fri Oct 9 07:00:09 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: [Project 1] - how would Transperth do it (fast)? From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none Thanks, for reposting my question Chris, and thanks for the detailed answer of how it "might" be implemented. Appreciate it! From 00014979@csse.uwa.edu.au Fri Oct 9 07:04:50 2015 Date: Fri Oct 9 07:04:50 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: [Project 1] - how would Transperth do it (fast)? From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Thanks, for reposting my question Chris, and thanks for the detailed answer of how it "might" be implemented. Just so that it's clear that the detailed answer wasn't from me.... (but it's a good followup) From lis63@csse.uwa.edu.au Fri Oct 9 09:48:25 2015 Date: Fri Oct 9 09:48:25 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.185.96 Subject: a warning on lab06 task 05 "implicit declaration of function `strdup'" From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > > > Hi, When I use strdup() in my code, I couldn't compile my code due to the warning: > > > > "implicit declaration of function `strdup'". > > > > > > Now I add "extern char *strdup(const char *s);" and the problem is solved. > > > > I just wonder why it happened. I have included string.h in my code and google tells > > me strdup is declared in string.h. > > > > Is there any other way to declare the function? > > > > By the way, I code on ubuntu. Not sure if it will happen on OSX. > > > strdup() is not a function defined by the C99 standard, so it will not be 'automatically' available > by just requesting C99 via your compiler. > > In the case of Linux, yes, the strdup() function's prototype appears in the header file > /usr/include/string.h but it is wrapped/hidden by a preprocessor conditional: > > #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 > /* Duplicate S, returning an identical malloc'd string. */ > extern char *strdup (__const char *__s); > #endif > > which states that if any of those other standard's tokens are defined, such as __USE_SVID, then the > prototype becomes visible to your code. > > > In the case of OS-X, its /usr/include/string.h wraps the strdup() prototype with preprocessor > conditions requiring certain versions of POSIX, which is predefined by Apple's C compiler when you > request C99: > > #if __DARWIN_C_LEVEL >= 200112L > char *strdup(const char *); > ...... > #endif /* __DARWIN_C_LEVEL >= 200112L */ Thank you. It's a very clear and detailed explanation. From graven01@csse.uwa.edu.au Fri Oct 9 09:50:42 2015 Date: Fri Oct 9 09:50:42 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Getopt() problem From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none So just working through this weeks lab sheets at home as I've been sick, and wondering why my code isn't working, it seems to skips the whole while loop when i run the following ./b trips.txt -l ./b trips.txt -w (i tried removing the switch statements and just printing a test line, but it never makes it inside the while loop for some reason) int main(int argc, char *argv[]) { int option; while ( (option = getopt(argc,argv, "wcl"))!= -1) { switch (option) { case 'w': printf("words"); break; case 'c': printf("characters"); break; case 'l': printf("lines"); break; } any suggestions to what I'm doing wrong would be appreciated. I've included #include (as stated is man 3 getopt) From 00014979@csse.uwa.edu.au Fri Oct 9 10:14:17 2015 Date: Fri Oct 9 10:14:17 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Exam revision From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > "Christopher McDonald" wrote: > > > (thanks for the kind comments) > > but try not to get caught in the (too) common belief that it's all about the lecture notes - some wrongly > > believe this to the point of just rote learning lecture notes, and reading nothing else. > > Honestly, I don't believe this to be fair. There are no guarantees that everyone will have the same opportunities to learn > everything that may or may not be expected to have been covered by an unknown textbook. I know we are given a list of > recommended textbooks, but different books will invariably cover different topics, or different scopes of the same topic. And > again, they are just "recommended"... How do we know if we are getting the right information if we use a different, but > similar textbook? Thanks for providing the comment (honestly; while we clearly differ on what's appropriate, it's helpful to receive any form of feedback, and hopefully others will contribute, too) On our OS-textbooks page: http://teaching.csse.uwa.edu.au/units/CITS2002/operating system-books.php I've listed 3 high-quality introductory textbooks - high-quality based on the large number of other universities using the same textbooks, awards won by their authors, online reviews, and my judgment after having read all 3. We're studying material based on operating systems, concrete artifacts that have evolved over 70 years to a well defined, and consistently documented, state (moreover, we're not actually studying anything state-of-the-art, but OS concepts that are 10 years old, and none very deeply) . Given the duration of our unit, the number of OS topics that can be covered is small - we've identified processes, memory-management, file-systems, and I/O. ALL of the 3 recommended textbooks covers each of these topics to the depth required of our Level-2 unit. The authors' writing is not subjective, I'm not expecting any student to read all 3 (or more), and it's not left to chance that you choose the "right one". The books are only listed as "recommended" because I don't wish to list any/them as "required" (the only other permitted category in UWA Handbooks). But specifying a single textbook as "required" requires (ineffectively) that all students have access to it, and students that have purchased it have an expectation that all of that exact book will be covered in depth, and nothing outside of that book. Experience also shows very few students actually buy CS textbooks, the Bookshop refuses to take the risk of stocking more than 1/3 of a unit's enrolment (restocking takes weeks), and there's very few 2nd hand copies available. > I believe that when it comes to examinations, we should only be examined on information we have all been provided fair and > equal opportunity to learn. And saying we have all been provided the opportunity to go and read all of the recommended texts > isn't fair either, as it is highly unlikely that we have the time to consume and comprehend that much information. Agreed - all students should, and do, have equal access to all information for the unit, but this doesn't require students to read all recommended textbooks; reading the clearly relevant sections of any of the 3 textbooks will do. I'm also trusting that students can, themselves, identify the relevant chapters from any of the books, and no-one has asked for such a clarification to date, week-10. Given that we have access to 3 very good textbooks, I strongly believe that providing a unit reader, paraphrasing the material from textbooks, is wasted effort. (CSSE used to provide unit-readers consisting of lecture slides and other information provided on our webpages, but given that HTML and PDF versions of everything are readily available, the Bookshop requires Schools to buy-back unsold copies, and students just stopped buying them, we stopped making them). What OS textbook have you been following in the unit, so far, and why do you believe (fear?) it's providing inadequate coverage of topics from the Unit Schedule? Examinations, particularly in 2nd year and higher units, are not about being able to reproduce information presented in any specific textbook or set or notes; they're about the student demonstrating that a unit's outcomes have been met, regardless of where the student sourced or derived their knowledge. I believe that it's quite reasonable to ask unseen questions in exams, that do not appear in a nominated textbook. Exams can reasonably ask for "new" information to be derived or reasoned during the exam; the equivalent in Mathematics would be being asked to prove a simple unseen theorem by drawing on other knowledge. In CS I believe it's quite reasonable for "competing" concepts X and Y to be identified, and for an exam to ask unseen questions such as "Under what circumstances does X fail?" or "When would you use X in preference to Y?". > And I do like that you provide opportunity for self learning. But at the same time, we still want to do well in our exams, > and with our grades - and we only have so much time to study. It would be great to have a list of specific topics that you > feel are *very* important and therefore will be examined so we can make notes of the other stuff, but not be worried about > focusing on the wrong content come exam time. I.e., more unambiguous guided self learning? I honestly don't believe there's opportunity for learning the wrong material. ALL topics listed on our unit schedule are relevant, ALL are important, and ALL are examinable (though not all will be examined). There's no "filler" material. From 00014979@csse.uwa.edu.au Fri Oct 9 10:18:41 2015 Date: Fri Oct 9 10:18:41 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Getopt() problem From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > ./b trips.txt -l Try with: ./b -l trips.txt (the options *before* the non-options) From graven01@csse.uwa.edu.au Fri Oct 9 10:44:46 2015 Date: Fri Oct 9 10:44:46 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.203.177 Subject: Getopt() problem From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > ./b trips.txt -l > > Try with: ./b -l trips.txt > (the options *before* the non-options) From graven01@csse.uwa.edu.au Fri Oct 9 16:01:10 2015 Date: Fri Oct 9 16:01:10 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: shortcuts From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none in the tutorial you showed a templete from an alias, i wonder if its possible (time permitting ) for to show us a bunch of "shortcuts" / aliases/tips and tricks especially vim wise (like replacing text quickly etc.) thanks. From chowda01@csse.uwa.edu.au Fri Oct 9 23:44:52 2015 Date: Fri Oct 9 23:44:52 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.112.22 Subject: Project 2 scheduled release date From: "Anirban Chowdhury" <21432966@student.uwa.edu.au> X-smilie: none X-img: none Hi, I was just wondering when project 2 will be released. Thanks in advance. From graven01@csse.uwa.edu.au Sat Oct 10 07:24:08 2015 Date: Sat Oct 10 07:24:08 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: 2014 final exam From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none The link is not working for me. would like to check it out if possible. Thanks From graven01@csse.uwa.edu.au Sat Oct 10 09:59:15 2015 Date: Sat Oct 10 09:59:15 2015 Edit: Sat Oct 10 10:04:14 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Xquartz From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none i wanted to give lab sheet q3 a go at home to play around with it. after compiling on OS X yosemite 10.10.5 i get : fatal error: 'X11/Xlib.h' file not found apparently according to the itnrawebz. newer versions of macs mountain lion etc + don't use x11 libraries, I've looked into installing xquartz and just wanted to check as i don't really know what I'm doing in regards to libraries and such. out of curiousity and risk of oversimplifying a question , why would they drop it? it seems a lot of people still use it / need it, although i have no idea what it does. thanks smart people for any insight you can offer my feeble brain. From godsat01@csse.uwa.edu.au Sat Oct 10 10:15:25 2015 Date: Sat Oct 10 10:15:25 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.235.22 Subject: Project 2 Partner From: "Thomas Godsall" <21504492@student.uwa.edu.au> X-smilie: none X-img: none Hey everyone, Im looking for a partner for the second project. I am available to meet up any time on Wednesdays, and can also meet up on Sundays and/or Friday afternoons if needed. If anyone is available during any of these times and is looking for a partner for the upcoming project, send me an email at 21504492@student.uwa.edu.au Thanks from Tom From liaoj02@csse.uwa.edu.au Sat Oct 10 20:45:21 2015 Date: Sat Oct 10 20:45:21 2015 Edit: Sat Oct 10 21:30:42 2015 To: help2002@csse.uwa.edu.au Received: from 43.252.114.236 Subject: LAB5 Q5 getting random number for dereferencing pointer From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none What I have done so far is void sortP(int src[], int *ptrs[], int n) { int *temp; for(int i = 0; i< n ; i++) { ptrs[i] = & src[i]; // assign the address of each number in the src[] to the array of pointers } while (1) { int flag = 0; // check if i < n-1, not n for(int i = 0; i< n-1;i++) { if ( *(ptrs[i]) > *(ptrs[i+1])) //bubble sort { temp = *(ptrs[i]); *(ptrs[i]) = *(ptrs[i+1]); *(ptrs[i+1]) = temp; flag = 1; } } if(flag == 0); break; } for(int i = 0; i< n;i++) { //*ptrs[i] instead of ptrs[i] printf("%i ",*ptrs[i]); } } In main function , I call this function main() { int a[5] = {5,7,1,8,10}; int *ptrs[5]= {&a[0],&a[1],&a[2],&a[3],&a[4]}; sortP(a, *ptrs, 5); } I got intial values without being swapped... why? THanks From liaoj02@csse.uwa.edu.au Sat Oct 10 22:30:49 2015 Date: Sat Oct 10 22:30:49 2015 Edit: Sat Oct 10 22:31:11 2015 To: help2002@csse.uwa.edu.au Received: from 43.252.114.236 Subject: LAB5 Q5 getting random number for dereferencing pointer From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none NVM,i got it void sortP(int src[], int *ptrs[], int n) { int *temp; int flag = 1; for(int i = 0; i< n ; i++) { ptrs[i] = & src[i]; // assign the address of each number in the src[] to the array of pointers } int i, j; for (i = 0; i < n - 1; i++) { for (j = 0; j < n - 1 - i; j++) if (*(ptrs[j]) > *(ptrs[j+1])) { temp = ptrs[j]; ptrs[j] = ptrs[j+1]; ptrs[j+1] = temp; } } for(int i = 0; i< n;i++) { //*ptrs[i] instead of ptrs[i] printf("%i ",*ptrs[i]); } } From abusha02@csse.uwa.edu.au Sun Oct 11 00:10:07 2015 Date: Sun Oct 11 00:10:07 2015 To: help2002@csse.uwa.edu.au Received: from 106.68.31.72 Subject: Are we going to get our project results before the end of semester? From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none Just wondering From 00014979@csse.uwa.edu.au Sun Oct 11 03:43:50 2015 Date: Sun Oct 11 03:43:50 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Are we going to get our project results before the end of semester? From: "Christopher McDonald" X-smilie: none X-img: none I don't believe that you're 'just wondering'; I believe that you're complaining facetiously, and choosing to do so anonymously. Like asking less that 2 days after the mid-semester test. Have a good weekend. From abusha02@csse.uwa.edu.au Sun Oct 11 12:54:49 2015 Date: Sun Oct 11 12:54:49 2015 To: help2002@csse.uwa.edu.au Received: from 106.68.31.72 Subject: Are we going to get our project results before the end of semester? From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > I don't believe that you're 'just wondering'; I believe that you're complaining > facetiously, and choosing to do so anonymously. > Like asking less that 2 days after the mid-semester test. > > Have a good weekend. With regards to the midsem, I wasn't really being facetious; I recall you mentioning something about results being released within 2 days, so I asked after 2 days. You clarified what you meant by the comment, which I was quite satisfied with, and I didn't ask again. With regards to this comment, I'll admit I was being facetious to an extent, but I also wrote "project" instead of "project 1" because I was quite curious about what will happen with the 2nd. Since it's been about 3 weeks since the project 1 submission, I can assume project 2 will take a similar length of time to mark. Given that, it's semi-justifiable for students to assume we won't be receiving project 2 results; it'd be impossible for them to be marked in the one week preceding the exam. Historically, I've never seen a unit release individual component results after its exam has concluded. Even after the exam's finished, I imagine students would like to see their project 2 results and feedback, which looks like it may not happen. In my own experience at UWA, once the exam has finished, students just have to settle for the final unit score, and give up on any unreleased results. Also, just to clarify the intent: my first complaint, while snarky, wasn't exactly a complaint about the length of the marking period. I don't have a problem with marking taking its due time; I just think it'd be nice to receive an ETA. Even if I'm told '4 weeks' upfront, I'd be happier with that than waiting 3.5 weeks without much indication of when I can expect to receive my results. Since the first comment was rude, I can change the question, if you're still willing to answer: Is it unlikely that we'll be receiving project 1 results by the time project 2 releases? Since I doubt project 2 could be humanly marked in only 1 week, I know we won't get them before the exam. But will we/can we still receive the results for that project, even after the exam's finished? From godsat01@csse.uwa.edu.au Sun Oct 11 15:26:59 2015 Date: Sun Oct 11 15:26:59 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.235.22 Subject: Project 2 Partner From: "Thomas Godsall" <21504492@student.uwa.edu.au> X-smilie: none X-img: none Found a partner. From 00014979@csse.uwa.edu.au Mon Oct 12 10:34:20 2015 Date: Mon Oct 12 10:34:20 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Project 2 scheduled release date From: "Christopher McDonald" X-smilie: none X-img: none And there it is! (just need to modify and upload the starting files mext) From 00014979@csse.uwa.edu.au Mon Oct 12 10:36:21 2015 Date: Mon Oct 12 10:36:21 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: 2014 final exam From: "Christopher McDonald" X-smilie: none X-img: none Confusing; does seem OK now - hopefully only a transient problem? From 00014979@csse.uwa.edu.au Mon Oct 12 10:50:52 2015 Date: Mon Oct 12 10:50:52 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Xquartz From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > doing in regards to libraries and such. out of curiousity and risk of oversimplifying a > question , why would they drop it? it seems a lot of people still use it / need it, > although i have no idea what it does. It's difficult to give a simple answer; it depends.... X11 is a client/server framework which enables bitmapped graphics to be displayed on a monitor, and even across a network. About 12 years ago Apple chose to 'ignore' X11 in favour of its graphics rendering, based on display-PDF. In some sense the two systems compete but, until the release of OSX 10.8 (Mountain Lion), Apple supported both systems. With ML, Apple dropped X11 support "out of the box", but they encourage those want ing X11 to install XQuartz, http://support.apple.com/kb/HT5293, which works very well. Tcl/Tk is a programming language with graphical primitives to draw things on graph ics displays. Apple eventually started providing Tcl/Tk about 8 years ago, by including it in Xcode as a native language (such as C, Objective-C, Swift....) Historically Tcl/Tk has required X11 to render its graphics, which means that we now need to install XQuartz on Mountain Lion (and beyond) to keep Tcl/Tk working. Apple has a bit of history in dropping software packages without much prior warning - but who doesn't (looking at you, Google). Apple had a hissy-fit in about 2010 when their voice on the SSL committees was not listened to, to their satisfaction. At that time, the SSL standard and its accepted APIs were changing quite quickly (and some critical errors appeared), and Apple felt unable to keep up with these, and unable to present a stable programming interface to their developers. From newmal01@csse.uwa.edu.au Mon Oct 12 10:53:03 2015 Date: Mon Oct 12 10:53:03 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.68.13 Subject: Linux Operating System From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none I am trying to download the linux operating system in place of the windows 10 OS I am just wandering which operating system to download since most linus OS use the same linux kernal From 00014979@csse.uwa.edu.au Mon Oct 12 10:58:18 2015 Date: Mon Oct 12 10:58:18 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Linux Operating System From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > I am trying to download the linux operating system in place of the windows 10 OS > I am just wandering which operating system to download since most linus OS use the > same linux kernal Most CSSE students seem to use Ubuntu - I'm unsure if that's a preference, or just that they see others using it. It'll be a good choice, though. Before you go too far, ensure that the web reports success by others using Linux on the same sort of hardware you're using. Quite a few reporting problems on the new MS Surface Pros. From graven01@csse.uwa.edu.au Mon Oct 12 11:07:47 2015 Date: Mon Oct 12 11:07:47 2015 Edit: Mon Oct 12 11:08:20 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Xquartz From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none Appreciate your thorough responses as usual, thank's From weinej01@csse.uwa.edu.au Mon Oct 12 13:08:12 2015 Date: Mon Oct 12 13:08:12 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.146.157 Subject: Project 2 Partner From: "Jake Weiner" <20749646@student.uwa.edu.au> X-smilie: none X-img: none If anyone is looking for a partner for the 2nd project send me an email 20749646@student.uwa.edu.au Cheers From graven01@csse.uwa.edu.au Mon Oct 12 14:04:36 2015 Date: Mon Oct 12 14:04:36 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Project 2 Partner From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none I'm looking for for a partner, but correspondence will have to be electronically as i cant get into campus much. 21256779@student.uwa.edu.au From zhangy56@csse.uwa.edu.au Mon Oct 12 14:13:54 2015 Date: Mon Oct 12 14:13:54 2015 To: help2002@csse.uwa.edu.au Received: from 180.216.60.20 Subject: Project 2 Partner From: "Yixin Zhang" <20866853@student.uwa.edu.au> X-smilie: none X-img: none I'm looking for a partner for this project. I'm happy to meet up and discuss the project this week. send me an email: 20866853@student.uwa.edu.au From 00014979@csse.uwa.edu.au Mon Oct 12 17:23:13 2015 Date: Mon Oct 12 17:23:13 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: 2nd project description and starting files available From: "Christopher McDonald" X-smilie: none X-img: none X-announcefor: 5d From: http://undergraduate.csse.uwa.edu.au/units/CITS2002/projects/project2.php As ever, any questions or requests for clarifications via our help forum. Answers to questions like "what should X do?" will usually be "what do standard shells do?". Those confused by the CMDTREE structure defined in mysh.h may get some assistance from the web-based program: https://secure.csse.uwa.edu.au/run/cmdtree which accepts a mysh command sequence, and then draws the CMDTREE structure returned by the parse_cmdtree() function. Good luck, From lopasb03@csse.uwa.edu.au Mon Oct 12 19:04:44 2015 Date: Mon Oct 12 19:04:44 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Trying to figure out project 2 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Hi, does anyone know if the shell files are supposed to compile, or are we supposed to fix the files so that we can compile mysh.c I am not sure what the deal is? From 00014979@csse.uwa.edu.au Mon Oct 12 19:25:38 2015 Date: Mon Oct 12 19:25:38 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Trying to figure out project 2 From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hi, does anyone know if the shell files are supposed to compile, or are we supposed > to fix the files so that we can compile mysh.c I am not sure what the deal is? They all compile, on both OS-X and Linux, when presented to the C compiler with our usual options (please tell me if otherwise). For the project you will be extending the provided files, mainly execute.c which currently does very little, and possibly adding/creating new files if you think they're necessary. As with the 1st project, you're STRONGLY encouraged to work with a project partner, and discuss these foundational concerns/problems as early as possible. From lopasb03@csse.uwa.edu.au Mon Oct 12 20:06:26 2015 Date: Mon Oct 12 20:06:26 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Trying to figure out project 2 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: baby.png X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > Hi, does anyone know if the shell files are supposed to compile, or are we supposed > > to fix the files so that we can compile mysh.c I am not sure what the deal is? > > They all compile, on both OS-X and Linux, when presented to the C compiler with our usual > options (please tell me if otherwise). > When I try to compile mysh.c as it is when I download the file, I am using the following cmd: cc -std=c99 -Wall -Werror -pedantic -o mysh mysh.c And I am getting the following error: Undefined symbols: "_interactive", referenced from: _interactive$non_lazy_ptr in ccU9HfgP.o (maybe you meant: _interactive$non_lazy_ptr) "_check_allocation0", referenced from: _main in ccU9HfgP.o _main in ccU9HfgP.o _main in ccU9HfgP.o "_execute_cmdtree", referenced from: _main in ccU9HfgP.o "_free_cmdtree", referenced from: _main in ccU9HfgP.o "_PATH", referenced from: _PATH$non_lazy_ptr in ccU9HfgP.o (maybe you meant: _PATH$non_lazy_ptr) "_argv0", referenced from: _argv0$non_lazy_ptr in ccU9HfgP.o (maybe you meant: _argv0$non_lazy_ptr) "_HOME", referenced from: _HOME$non_lazy_ptr in ccU9HfgP.o (maybe you meant: _HOME$non_lazy_ptr) "_CDPATH", referenced from: _CDPATH$non_lazy_ptr in ccU9HfgP.o (maybe you meant: _CDPATH$non_lazy_ptr) "_parse_cmdtree", referenced from: _main in ccU9HfgP.o ld: symbol(s) not found collect2: ld returned 1 exit status It's probably something really simple right, but I'm not seeing it, I am using a gcc machine, so I am actually using: gcc -std=c99 -Wall -Werror -pedantic -o mysh mysh.c But I still get the above error? Can anybody tell me if I am doing something wrong, thanks. From fetzee01@csse.uwa.edu.au Mon Oct 12 20:31:30 2015 Date: Mon Oct 12 20:31:30 2015 Edit: Mon Oct 12 20:32:00 2015 To: help2002@csse.uwa.edu.au Received: from 122.111.251.220 Subject: Trying to figure out project 2 From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none Try writing your makefile (as described in the lectures), with all the suitable dependencies! Don't try and compile source files individually, it would be very tedious. From lopasb03@csse.uwa.edu.au Mon Oct 12 20:57:14 2015 Date: Mon Oct 12 20:57:14 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Trying to figure out project 2 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Thanks for the input fellas, it works fine when I use: gcc -std=c99 -Wall -Werror -pedantic -o mysh mysh.c globals.c parser.c execute.c Cheers. From lopasb03@csse.uwa.edu.au Tue Oct 13 00:28:21 2015 Date: Tue Oct 13 00:28:21 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Break it down for us From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: insane.png X-img: none So, I spent the first day of the project trying to figure out how everything fits together, but I am still lost. Can you either add some clarifications, comments, or stuff on here so I can try to figure out how everything fits together. I don't want to spend the whole week just trying to get a grasp on the different .c and .h files, otherwise I will probably run out of time like the last project. Cheers. From 00014979@csse.uwa.edu.au Tue Oct 13 07:23:31 2015 Date: Tue Oct 13 07:23:31 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Are we going to get our project results before the end of semester? From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Also, just to clarify the intent: my first complaint, while snarky, wasn't exactly a > complaint about the length of the marking period. I don't have a problem with > marking taking its due time; I just think it'd be nice to receive an ETA. Even if > I'm told '4 weeks' upfront, I'd be happier with that than waiting 3.5 weeks without > much indication of when I can expect to receive my results. OK, I've misunderstood your comment (wasn't expecting anyone to ask about the marking of the 2nd project until it was handed out). But your summary is correct - it's extremely unlikely that the marks of the 2nd project will be known before the final exam (I wasn't aware that students, yet, have their exam timetables). Though we'll hand the project's sample solution out well before the exam. Regarding your question/concern about the marking of the 1st project - it's almost done; both Amar and JT completed the 'manual' inspection of each submission's code while I was overseas last week (102 submissions). It's been (annoyingly) difficult to put any ETA on the completion of the automated part of the marking; while I was anticipating some submissions taking longer to run, and have allowed for that (and checked for a few infinite loops), there's a surprising number of submissions that produce sensible though 'random' output - "walk for 6mins to bustop 12348" - which makes it very difficult to parse and mark 'automatically'. And I'm sure that those students won't want a zero for those tests. Ploughing on. From tayi02@csse.uwa.edu.au Tue Oct 13 08:35:48 2015 Date: Tue Oct 13 08:35:48 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.157.168 Subject: Project 2 Partner From: "Ian Tay" <20939902@student.uwa.edu.au> X-smilie: none X-img: none Hi, I am looking for a partner for project 2. Please send me an email at 20939902@student.uwa.edu.au From 00014979@csse.uwa.edu.au Tue Oct 13 09:15:15 2015 Date: Tue Oct 13 09:15:15 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Break it down for us From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > I don't want to spend the whole week just trying to get a grasp on the different .c > and .h files, otherwise I will probably run out of time like the last project. Agreed, spending a week just understanding the starting files would be disproportionate, but we really have very few files, here. Understanding the starting materials is not, however, wasted effort, as the project is not one being completed by just filling in some missing pieces. Firstly, you've asked for a *clarification* - what would you like clarifying, from what you've already discovered what's unclear to you? What do you think/understand that you need to develop, and what do you understand has already been provided for you? Have you been discussing what's going on with a project partner as, again, it's a project that you will best complete by working with someone. From dewarj02@csse.uwa.edu.au Tue Oct 13 11:26:30 2015 Date: Tue Oct 13 11:26:30 2015 To: help2002@csse.uwa.edu.au Received: from 180.216.13.54 Subject: Project 2 Partner From: "Jye Dewar" <21488841@student.uwa.edu.au> X-smilie: none X-img: none If anyone is looking for a project 2 partner email me at 21488841@student.uwa.edu.au From weinej01@csse.uwa.edu.au Tue Oct 13 11:55:27 2015 Date: Tue Oct 13 11:55:27 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.146.157 Subject: Makefile tab problem From: "Jake Weiner" <20749646@student.uwa.edu.au> X-smilie: none X-img: none Has anyone else had problems on a macbook pro with "Makefile:7: *** missing separator. Stop." Which i'm assuming is because of a tab error but i have tabs in my textfile? C99 = cc -std=c99 CFLAGS = -Wall -pedantic -Werror arraystest : stringtest.o arrays.o $(C99) $(CFLAGS) -o arraystest stringtest.o arrays.o stringtest.o : stringtest.c arrays.h $(C99) $(CFLAGS) -c stringtest.c arrays.o : arrays.c arrays.h $(C99) $(CFLAGS) -c arrays.c clean: rm -f *.o arraystest From luj20@csse.uwa.edu.au Tue Oct 13 11:57:31 2015 Date: Tue Oct 13 11:57:31 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.133 Subject: Tutorial 8 sample solution From: "Juan Lu" <21691401@student.uwa.edu.au> X-smilie: none X-img: none Just wondering if there will be a sample solution for tutorial 8 as before. From lopasb03@csse.uwa.edu.au Tue Oct 13 12:37:26 2015 Date: Tue Oct 13 12:37:26 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Makefile error From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: rolleyes.png X-img: none Does anyone know why I may be getting this error when I type make at the prompt: "make: *** No targets specified and no makefile found. Stop." These are the files I have in my directory: Makefile.txt globals.c mysh.h execute.c mysh.c parser.c From 00014979@csse.uwa.edu.au Tue Oct 13 12:50:57 2015 Date: Tue Oct 13 12:50:57 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Makefile error From: "Christopher McDonald" X-smilie: none X-img: none Remove the ".txt" extension. From 00014979@csse.uwa.edu.au Tue Oct 13 12:52:54 2015 Date: Tue Oct 13 12:52:54 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Makefile tab problem From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Has anyone else had problems on a macbook pro with > > "Makefile:7: *** missing separator. Stop." > > Which i'm assuming is because of a tab error but i have tabs in my textfile? In your editor do you have soft-tabs expanded to 4 spaces? If you run od -c Makefile do you see leading \t s in the output? From 00014979@csse.uwa.edu.au Tue Oct 13 12:53:12 2015 Date: Tue Oct 13 12:53:12 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Tutorial 8 sample solution From: "Christopher McDonald" X-smilie: none X-img: none There now. From lopasb03@csse.uwa.edu.au Tue Oct 13 13:03:25 2015 Date: Tue Oct 13 13:03:25 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Break it down for us From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: verytired2.png X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > I don't want to spend the whole week just trying to get a grasp on the different .c > > and .h files, otherwise I will probably run out of time like the last project. > > Agreed, spending a week just understanding the starting files would be disproportionate, but > we really have very few files, here. Understanding the starting materials is not, however, > wasted effort, as the project is not one being completed by just filling in some missing > pieces. > > Firstly, you've asked for a *clarification* - what would you like clarifying, from what you've > already discovered what's unclear to you? What do you think/understand that you need to > develop, and what do you understand has already been provided for you? > > Have you been discussing what's going on with a project partner as, again, > it's a project that you will best complete by working with someone. I am more or less just trying to get an understanding of where to get started (ie. for step 1). I understand that mysh.h is just the header file, and doesn't need to be changed. globals.c is supposed to initialise the variables defined in the header file, so that we can use them "globally", however at the moment it doesn't do that, am I on the right track? I also understand that mysh.c only contains the main function, so is that its only purpose, I understand that some work will need to be done here? Then I understand that parser.c does all the leg work in parsing the text at our cmd line. This file does not need any work done to it? So, that just leaves execute.c, where I understand most of our work will be in here. Now for step 1, do we have to sift through parser.c to use the correct functions in execute.c ? If so, which function would we use to parse the first part of the first step? I don't see any functions where there is anything done when the cmd line encounters a '/' From lopasb03@csse.uwa.edu.au Tue Oct 13 13:08:03 2015 Date: Tue Oct 13 13:08:03 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Makefile error From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: verytired.png X-img: none Ok, I did that and now I get this error, and I don't understand what it means? " rm -f mysh.o globals.o execute.o parser.o " make: mysh: No such file or directory make: *** [clean] Error 1 I'm thinking its something to do with -f , anybody know? From weinej01@csse.uwa.edu.au Tue Oct 13 14:04:51 2015 Date: Tue Oct 13 14:04:51 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.146.157 Subject: Makefile tab problem From: "Jake Weiner" <20749646@student.uwa.edu.au> X-smilie: none X-img: none Ah ok i see. Xcode apparently uses 4 white spaces as a tab but managed to change that. Thanks for your help! From radham02@csse.uwa.edu.au Tue Oct 13 14:40:49 2015 Date: Tue Oct 13 14:40:49 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.118.76 Subject: Project 2 Partner From: "Mugundan Radhakrishnan" <21493083@student.uwa.edu.au> X-smilie: none X-img: none If anyone is still after a partner, send me an email at 21493083@student.uwa.edu.au From mcfald01@csse.uwa.edu.au Tue Oct 13 14:46:25 2015 Date: Tue Oct 13 14:46:25 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.178.38 Subject: Project 2 Partner From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none Hey, If anyone is looking for a partner just email me at 21312007@student.uwa.edu.au Would prefer someone on campus to discuss in the coming days so we can get a good start on it and not leave for last minute. Cheers From 00014979@csse.uwa.edu.au Tue Oct 13 15:08:34 2015 Date: Tue Oct 13 15:08:34 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Break it down for us From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > I am more or less just trying to get an understanding of where to get started (ie. for step 1). I > understand that mysh.h is just the header file, and doesn't need to be changed. True, doesn't need to be changed, but ensure that you understand its contents - particularly the user- defined type named CMDTREE > globals.c is supposed to initialise the variables defined in the header file, so that we can use > them "globally", however at the moment it doesn't do that, am I on the right track? globals.c *defines* a few global variables, each of which is *declared* in mysh.h As the mysh.h header file is #include-d by all other C files, all C files have knowledge of these global variables. The global variables *HOME, *PATH, *CDPATH are *initialised* in mysh.c > I also understand that mysh.c only contains the main function, so is that its only purpose, I > understand that some work will need to be done here? Later steps will need to add to this file. > Then I understand that parser.c does all the leg work in parsing the text at our cmd line. This > file does not need any work done to it? AS ITS COMMENTS SAY, no need to change this file. > > So, that just leaves execute.c, where I understand most of our work will be in here. And to get you started, read the comment in main() about calling print_cmdtree(t), then read the implementation of print_cmdtree0() in globals.c > Now for step 1, do we have to sift through parser.c to use the correct functions in execute.c ? If > so, which function would we use to parse the first part of the first step? I don't see any > functions where there is anything done when the cmd line encounters a '/' AS ITS COMMENTS SAY, no need to understand nor modify parser.c _____ Do you have a project partner? It will help enormously. From tans121@csse.uwa.edu.au Tue Oct 13 15:31:20 2015 Date: Tue Oct 13 15:31:20 2015 To: help2002@csse.uwa.edu.au Received: from 58.110.162.120 Subject: Project 2 Confusions From: "Shao-Ming Tan" <20920822@student.uwa.edu.au> X-smilie: none X-img: none Hi, Are we suppose to write the shell functions like ls and cal with their options and if so where do we limit the functions we write or do we write the "shell" such that it can run programs with the &&, || etc. stuff? I'm a bit confused on how to start, I've already read all the files and not sure how to tackle this project, any tips? And a question on the CMDTREE type, what is the purpose of the subtrees/ left and right things? Aren't all the arguments that will be supplied to mysh being stored in the **argv in the CMDTREE? From lopasb03@csse.uwa.edu.au Tue Oct 13 16:07:18 2015 Date: Tue Oct 13 16:07:18 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Break it down for us From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: hot.png X-img: none "Christopher McDonald" wrote: > Do you have a project partner? It will help enormously. Yeah, I have a project partner, but we are both on the same page. We are both still trying to figure out how to approach it, and are going through some of the course material to try to find some things that could help us get our heads around this project. The more times I read the code in the files I seem to pick up a little more each time, but we will both be going to tomorrows labs because we need to get started fast, if the difficulty of this project is anything like the first one. I can only speak for myself, but I think I need more precise instructions for each step. Thanks. From lopasb03@csse.uwa.edu.au Tue Oct 13 17:03:54 2015 Date: Tue Oct 13 17:03:54 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Makefile error From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > Ok, I did that and now I get this error, and I don't understand what it means? > > " rm -f mysh.o globals.o execute.o parser.o " > make: mysh: No such file or directory > make: *** [clean] Error 1 > > I'm thinking its something to do with -f , anybody know? I get the same problem when I run my header file: ....... Does anybody know why? [Please don't post parts of the project which are assessed - Chris.] From lopasb03@csse.uwa.edu.au Tue Oct 13 17:06:02 2015 Date: Tue Oct 13 17:06:02 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Project 2 Confusions From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Does anybody have any ideas? I am in the same boat as anonymous. :( From graven01@csse.uwa.edu.au Tue Oct 13 18:09:13 2015 Date: Tue Oct 13 18:09:13 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Project 2 Confusions From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none I have a feeling things will be come clearer as you progress through the "suggested" steps of the program, i hope anyway, i think the understanding will be the most challenging part of the problem :D i first looked at it and though "oh shit" but now i am (very) slowly feeling better about it. From flemiw02@csse.uwa.edu.au Tue Oct 13 18:37:33 2015 Date: Tue Oct 13 18:37:33 2015 Edit: Tue Oct 13 18:40:31 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.191.2 Subject: Project 2 Partner From: "William Fleming" <21130644@student.uwa.edu.au> X-smilie: none X-img: none Looking for a project 2 partner. email 21130644@student.uwa.edu.au if keen. FYI I am still catching up on some past content but should be good within a few days. Can meet up most times of the week. From tans121@csse.uwa.edu.au Tue Oct 13 19:55:25 2015 Date: Tue Oct 13 19:55:25 2015 To: help2002@csse.uwa.edu.au Received: from 58.110.162.120 Subject: Break it down for us From: "Shao-Ming Tan" <20920822@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > "Christopher McDonald" wrote: > > > > Do you have a project partner? It will help enormously. > > Yeah, I have a project partner, but we are both on the same page. We are both still trying to figure out how > to approach it, and are going through some of the course material to try to find some things that could help > us get our heads around this project. > > The more times I read the code in the files I seem to pick up a little more each time, but we will both be > going to tomorrows labs because we need to get started fast, if the difficulty of this project is anything > like the first one. > > I can only speak for myself, but I think I need more precise instructions for each step. > > Thanks. I am in the same situation as OP, I understand a bit of what the files do but not how I'm suppose to progress with the project From newmal01@csse.uwa.edu.au Tue Oct 13 21:17:28 2015 Date: Tue Oct 13 21:17:28 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.68.13 Subject: Are we going to get our project results before the end of semester? From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none Crack that whip Anonymus!!! From 00014979@csse.uwa.edu.au Wed Oct 14 07:27:58 2015 Date: Wed Oct 14 07:27:58 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Break it down for us From: "Christopher McDonald" X-smilie: none X-img: none Those confused by the CMDTREE structure defined in mysh.h may get some assistance from the web-based program: https://secure.csse.uwa.edu.au/run/cmdtree which accepts a mysh command sequence, and then draws the CMDTREE structure returned by the function parse_cmdtree(). From bradfj01@csse.uwa.edu.au Wed Oct 14 13:00:21 2015 Date: Wed Oct 14 13:00:21 2015 To: help2002@csse.uwa.edu.au Received: from 49.196.9.16 Subject: Make file ? From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none Hi all, I'm still a little confused at what make file does, I think it is meant to compile all of the files together rather than having to compile each one. Please let me know if I'm on some flying tangent and have no idea what I'm talking about. Thank you :) From lopasb03@csse.uwa.edu.au Wed Oct 14 13:48:07 2015 Date: Wed Oct 14 13:48:07 2015 Edit: Wed Oct 14 13:50:17 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step 2. Search Path From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Does anyone know if we have to initialize the PATH pointer to point to the DEFAULT_PATH in globals.c before we can begin searching for the correct command? Scratch the above question I just realized that it is initialized in main. From 00014979@csse.uwa.edu.au Wed Oct 14 14:22:30 2015 Date: Wed Oct 14 14:22:30 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Step 2. Search Path From: "Christopher McDonald" X-smilie: question.png X-img: none I'm confidently assuming that you've got Step 1 working :-) From lopasb03@csse.uwa.edu.au Wed Oct 14 14:44:21 2015 Date: Wed Oct 14 14:44:21 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step 2. Search Path From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Yeah, thanks Chris, I got it working in todays lab. c",) From 00014979@csse.uwa.edu.au Wed Oct 14 15:08:24 2015 Date: Wed Oct 14 15:08:24 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Make file ? From: "Christopher McDonald" X-smilie: none X-img: none I've been anticipating/hoping that someone would have pointed you to Lecture 13. Is there still something in there that's unclear? From lopasb03@csse.uwa.edu.au Wed Oct 14 16:30:49 2015 Date: Wed Oct 14 16:30:49 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step 2. Search Path From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Still working on this step, and I was wondering if anyone knew how to avoid getting the error "fork(): Resource Temporarily Unavaliable" , I have to keep restarting my machine and now I can only do about 5 forks before it happens. Is there a way to clear all the previous processes I have started. ie do I have to kill something or can I set a larger maximum limit for the number of processes I can use? Any help would be appreciated, Cheers. From bradfj01@csse.uwa.edu.au Wed Oct 14 16:51:03 2015 Date: Wed Oct 14 16:51:03 2015 To: help2002@csse.uwa.edu.au Received: from 203.63.157.102 Subject: Make file ? From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > Lecture 13. AHA! Thank you, I can't believe I couldn't remember. Thank you for pointing me in the right direction! From motts02@csse.uwa.edu.au Wed Oct 14 18:51:34 2015 Date: Wed Oct 14 18:51:34 2015 Edit: Wed Oct 14 18:54:42 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.98.46 Subject: Make file - Circular Dependency From: "Stephen Mott" <21140413@student.uwa.edu.au> X-smilie: none X-img: none Hi all; I'm having trouble with my makefile. Currently, it is compiling all of the things it's meant to compile, however, it gives me the following error and fails to execute the rm command. make: Circular mysh.o <- mysh dependency dropped. cc -std=c99 -Wall -pedantic -Werror -c mysh.c make: Circular execute.o <- mysh dependency dropped. cc -std=c99 -Wall -pedantic -Werror -c execute.c make: Circular globals.o <- mysh dependency dropped. cc -std=c99 -Wall -pedantic -Werror -c globals.c make: Circular parser.o <- mysh dependency dropped. cc -std=c99 -Wall -pedantic -Werror -c parser.c cc -std=c99 -Wall -pedantic -Werror -o mysh mysh.o execute.o globals.o parser.o -lm The order that I'm doing things is 1. define variables (to be used by $(variable)). 2. create .o files. 3. compile program with .o files 4. clean .o files. I tried running the cc______ commands generated by the above, and they all seem to work. Likewise, I've tried running the rm -f projectname objectfile command from the terminal and it seems to work as intended. I'm really not sure of why this isn't working. If anyone can point out some methods to troubleshoot this I'd appreciate it. -Stephen From 00014979@csse.uwa.edu.au Wed Oct 14 19:04:26 2015 Date: Wed Oct 14 19:04:26 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Make file - Circular Dependency From: "Christopher McDonald" X-smilie: none X-img: none "Stephen Mott" <21140413@student.uwa.edu.au> wrote: > make: Circular mysh.o <- mysh dependency dropped. It looks like you have your mysh.o file dependent on your mysh target (and the other way around). Do you mean mysh.h ? From motts02@csse.uwa.edu.au Wed Oct 14 19:21:40 2015 Date: Wed Oct 14 19:21:40 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.98.46 Subject: Make file - Circular Dependency From: "Stephen Mott" <21140413@student.uwa.edu.au> X-smilie: none X-img: none Thanks Chris, that was the issue. I had accidentally written the dependencies for the .c files as "mysh" instead of "mysh.h" From lopasb03@csse.uwa.edu.au Wed Oct 14 19:34:24 2015 Date: Wed Oct 14 19:34:24 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step 2. Search Path From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Does anybody know of a command we can use to test step 2? From liaoj02@csse.uwa.edu.au Wed Oct 14 21:21:45 2015 Date: Wed Oct 14 21:21:45 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.124.192 Subject: Lab Week 10 Q4 free memory From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none // DEALLOCATE THE MEMORY HOLDING THE LINES for(int i=0 ; i X-smilie: none X-img: none Does anyone know how to determine when the required command is found? From newmal01@csse.uwa.edu.au Wed Oct 14 23:59:23 2015 Date: Wed Oct 14 23:59:23 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.127 Subject: functions returning pointers From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none i am just wondering as how the functions which return a pointer value would be called from the main function or others example char *strcpy_array( char dest[], char src[] ) // returns a pointer { int i = 0; while( src[i] != '\0' ) { dest[ i ] = src[ i ]; ++i; } dest[ i ] = '\0'; return dest; // returns the original destination parameter } From 00014979@csse.uwa.edu.au Thu Oct 15 06:42:20 2015 Date: Thu Oct 15 06:42:20 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Lab Week 10 Q4 free memory From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > // DEALLOCATE THE MEMORY HOLDING THE LINES > for(int i=0 ; i free(lines[i]); > } > free(lines); > } > I dont understand why it needs to be freed twice? Because there is no single 'it'. 'lines' is a dynamically allocated vector of pointers, and the *whole* vector eventually needs deallocating. And each element of 'lines', itself, points to dynamically allocated memory so, eventually, *each element* needs to be deallocated too. From 00014979@csse.uwa.edu.au Thu Oct 15 07:13:45 2015 Date: Thu Oct 15 07:13:45 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: functions returning pointers From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > i am just wondering as how the functions which return a pointer value would be called from > the main function or others I'm unsure where your confusion could lie; we've already seen a number of standard functions which return pointers, including fopen(), malloc(), and strdup(). We didn't need to call them in any special way - we just assigned their returned value to a pointer variable. From lopasb03@csse.uwa.edu.au Thu Oct 15 07:20:21 2015 Date: Thu Oct 15 07:20:21 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: step 3. calling exit() From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none I have a problem when calling exit(), I am getting the following error: " mysh(581) malloc: *** error for object 0x25d1: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug " Even though the pointer in question has been properly allocated, does anyone know what may be going wrong? Cheers. c",) From 00014979@csse.uwa.edu.au Thu Oct 15 07:26:01 2015 Date: Thu Oct 15 07:26:01 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Step 2. Search Path From: "Christopher McDonald" X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > Still working on this step, and I was wondering if anyone knew how to avoid getting > the error "fork(): Resource Temporarily Unavaliable" , I have to keep restarting my > machine and now I can only do about 5 forks before it happens. This sounds like you're creating a "runaway" sequence of new processes and, eventually, a call to fork() fails because no further processes can be created. If a process no longer needs to run, then its code should call exit(). From 00014979@csse.uwa.edu.au Thu Oct 15 07:27:43 2015 Date: Thu Oct 15 07:27:43 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Step 2. Search Path From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Does anybody know of a command we can use to test step 2? Unclear; if you've completed Step 1, which provided the exact/known pathname to a required program, such as /bin/ls, then you can test Step 2 by just requesting ls and it should be found in the directory /bin From 00014979@csse.uwa.edu.au Thu Oct 15 07:28:17 2015 Date: Thu Oct 15 07:28:17 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Step 2. Search Path From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Does anyone know how to determine when the required command is found? If it *can't* be found, then the call to attempt to execute it will fail. From 00014979@csse.uwa.edu.au Thu Oct 15 07:29:43 2015 Date: Thu Oct 15 07:29:43 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: step 3. calling exit() From: "Christopher McDonald" X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > Even though the pointer in question has been properly allocated, does anyone know > what may be going wrong? The pointer in question was *not* previously allocated, from a call to malloc or realloc. From 00014979@csse.uwa.edu.au Thu Oct 15 07:30:19 2015 Date: Thu Oct 15 07:30:19 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Break it down for us From: "Christopher McDonald" X-smilie: none X-img: none "Christopher McDonald" wrote: > Those confused by the CMDTREE structure defined in mysh.h may get some assistance from the web-based program: > > https://secure.csse.uwa.edu.au/run/cmdtree > > which accepts a mysh command sequence, and then draws the CMDTREE structure returned by the function parse_cmdtree(). Has anyone found this helpful? From lopasb03@csse.uwa.edu.au Thu Oct 15 07:55:09 2015 Date: Thu Oct 15 07:55:09 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: step 3. calling exit() From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > > > Even though the pointer in question has been properly allocated, does anyone know > > what may be going wrong? > > The pointer in question was *not* previously allocated, from a call to malloc or realloc. Is this not the correct way to allocate a pointer memory, and then use the memory: char *y = (char*)malloc(4*sizeof(char)); strcpy(y, "yes"); From lopasb03@csse.uwa.edu.au Thu Oct 15 07:55:54 2015 Date: Thu Oct 15 07:55:54 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Break it down for us From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Yeah, it is very helpful, thanks. c",) From 00014979@csse.uwa.edu.au Thu Oct 15 07:59:09 2015 Date: Thu Oct 15 07:59:09 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: step 3. calling exit() From: "Christopher McDonald" X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > Is this not the correct way to allocate a pointer memory, and then use the memory: > > char *y = (char*)malloc(4*sizeof(char)); > strcpy(y, "yes"); Yes, that's correct (though don't cast the returned value of malloc). But, it's very unlikely that malloc() will be reporting an error for the above; are you sure that's the exact case in error? I bet if you add free(y); after that code, that it will work. From newmal01@csse.uwa.edu.au Thu Oct 15 08:42:30 2015 Date: Thu Oct 15 08:42:30 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.95.192 Subject: functions returning pointers From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none its just confusing me as to the reason the function would only return a pointer which hold the address of the the first character in the array? From lopasb03@csse.uwa.edu.au Thu Oct 15 08:43:40 2015 Date: Thu Oct 15 08:43:40 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: step 3. calling exit() From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > > > Is this not the correct way to allocate a pointer memory, and then use the memory: > > > > char *y = (char*)malloc(4*sizeof(char)); > > strcpy(y, "yes"); > > Yes, that's correct (though don't cast the returned value of malloc). > > But, it's very unlikely that malloc() will be reporting an error for the above; > are you sure that's the exact case in error? > I bet if you add free(y); after that code, that it will work. Yes, I have just discovered that it is not malloc() reporting the error for the above, the problem is occurring when I type exit at my shells command line. I have tried to put in a conditional to catch the "exit" command and then use: "kill(pid, SIGKILL);" but I am still getting the malloc error? Anybody have any thoughts? Cheers, Ben. c",) From chanej01@csse.uwa.edu.au Thu Oct 15 10:47:37 2015 Date: Thu Oct 15 10:47:37 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.145.2 Subject: Project 2 Partner From: "Jonathan Chaney" <21335128@student.uwa.edu.au> X-smilie: none X-img: none Hey looking for project 2 partner, Email me at 21335128@student.uwa.edu.au if you need one. From 00014979@csse.uwa.edu.au Thu Oct 15 10:47:46 2015 Date: Thu Oct 15 10:47:46 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: functions returning pointers From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > its just confusing me as to the reason the function would only return a pointer which hold the address of the > the first character in the array? I'm focusing on your use of the word *only*, and thinking that you're wanting the function to return something additional, or something else. The example function that you used returns a pointer to a character, yes, because it's supporting string-based operations. As C doesn't support a base string datatype, all functions supporting string operations deal with pointers to a single character, and all assume that the following characters in the same string appear at physically higher, contiguous, addresses. ?? From newmal01@csse.uwa.edu.au Thu Oct 15 12:44:37 2015 Date: Thu Oct 15 12:44:37 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.95.192 Subject: functions returning pointers From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > its just confusing me as to the reason the function would only return a pointer which hold the address of the > > the first character in the array? > > I'm focusing on your use of the word *only*, > and thinking that you're wanting the function to return something additional, or something else. > > The example function that you used returns a pointer to a character, yes, because it's supporting string-based operations. > As C doesn't support a base string datatype, all functions supporting string operations deal with pointers to a single > character, and all assume that the following characters in the same string appear at physically higher, contiguous, > addresses. > > ?? Oh so to return a character array from a function you can simply return a pointer to the first character within said array And increase the address the pointer points to by 1 until you reach the null byte? From liaoj02@csse.uwa.edu.au Thu Oct 15 14:25:48 2015 Date: Thu Oct 15 14:25:48 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.122 Subject: Step 2 getting the path name From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Hello. When I try to pass the PATH into execv, am I suppose to append a "/ls" to it? Moreover, when I printing PATH, I got the dsomething like /bin:usr/bin:/usr which is not /bin that is desired.. Thanks From weinej01@csse.uwa.edu.au Thu Oct 15 14:29:51 2015 Date: Thu Oct 15 14:29:51 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.146.157 Subject: Step 2 getting the path name From: "Jake Weiner" <20749646@student.uwa.edu.au> X-smilie: none X-img: none yeh i'm getting the same problem... when i use echo $PATH I'm not sure if it is returning separate path variables e.g /bin, /usr/bin, or if it is just one long path that we need to then parse into separate components From 00014979@csse.uwa.edu.au Thu Oct 15 14:46:05 2015 Date: Thu Oct 15 14:46:05 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Step 2 getting the path name From: "Christopher McDonald" X-smilie: none X-img: none "Jake Weiner" <20749646@student.uwa.edu.au> wrote: > yeh i'm getting the same problem... when i use echo $PATH I'm not sure if it is returning > separate path variables e.g /bin, /usr/bin, or if it is just one long path that we need to then > parse into separate components The latter. From the project spec.: "The global variable PATH points to a character string which is interpreted as a colon separated list of directory names." From lopasb03@csse.uwa.edu.au Thu Oct 15 16:38:51 2015 Date: Thu Oct 15 16:38:51 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step3. part 2 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none I am having trouble appending my child processes pwd. I have created a file called "stuff" and put another file called "more stuff" in it just to see if my process is working. when I check my file name it prints ".../mysh/stuff", however when I call 'pwd' mysh only prints out ".../mysh". I am using the following to change the directories: execvp(newpwd, t -> argv); where, newpwd = ".../mysh/stuff" Is the new path suppossed to be ".../mysh/stuff" when I call pwd, or is there further stuff down the track in another step we must use to link pieces together. As I have noticed that step 3 part 2 says "....,then mysh should *attempt* to change from the current working (default) directory to the directory specified as the first argument to the cd command." If anybody could shed some light on this, that would be great. Cheers, c",) From liaoj02@csse.uwa.edu.au Thu Oct 15 16:49:12 2015 Date: Thu Oct 15 16:49:12 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.122 Subject: Step 2 getting the path name From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none So we have to break field using ':' as delimiter then try each possible field? From 00014979@csse.uwa.edu.au Thu Oct 15 16:53:56 2015 Date: Thu Oct 15 16:53:56 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Step 2 getting the path name From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > So we have to break field using ':' as delimiter then try each possible field? How about rethinking the question, so that it's not one of "Chris, do we have to ....", to one of "Self, I wonder if this approach will work? Why don't I use the wonderful experimental tool, the computer in front of me, to see what works?" :-) From 00014979@csse.uwa.edu.au Thu Oct 15 17:09:35 2015 Date: Thu Oct 15 17:09:35 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: functions returning pointers From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Oh so to return a character array from a function you can simply return a pointer to the first character within said array Yes, works for arrays of any type, not just characters. Review the lecture on the motivation for the strdup() function. > And increase the address the pointer points to by 1 until you reach the null byte? Yes. What we can do with returned character-pointers/strings, is no different to what we can do with them inside a function. From chinnd01@csse.uwa.edu.au Thu Oct 15 19:08:15 2015 Date: Thu Oct 15 19:08:15 2015 To: help2002@csse.uwa.edu.au Received: from 110.141.145.3 Subject: Project 2 Confusions From: "David Chinnery" <21142701@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > Hi, > > Are we suppose to write the shell functions like ls and cal with their options and if > so where do we limit the functions we write or do we write the "shell" such that it > can run programs with the &&, || etc. stuff? > > I'm a bit confused on how to start, I've already read all the files and not sure how > to tackle this project, any tips? > > And a question on the CMDTREE type, what is the purpose of the subtrees/ left and > right things? Aren't all the arguments that will be supplied to mysh being stored in > the **argv in the CMDTREE? No you don't, look up the exec family of commands. IMHO start with familarising yourself with how the CMDTREE works which brings me to your next point. The left and right is for the semicolon entries. Have a go at the web thing on the clarifactions page and you will see what its for. Hope that helps :) From fetzee01@csse.uwa.edu.au Thu Oct 15 23:00:55 2015 Date: Thu Oct 15 23:00:55 2015 To: help2002@csse.uwa.edu.au Received: from 122.111.245.242 Subject: Can a successful solution only involve extending execute.c ? From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none Hi, can a successful solution only involve extending execute.c ? (So, the program requirements can be met through only adding code to execute.c ?). Thank you. From fetzee01@csse.uwa.edu.au Thu Oct 15 23:32:00 2015 Date: Thu Oct 15 23:32:00 2015 To: help2002@csse.uwa.edu.au Received: from 122.111.245.242 Subject: Project 2 Confusions From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none thanks David, it does help a bit with getting started. From lopasb03@csse.uwa.edu.au Fri Oct 16 08:08:27 2015 Date: Fri Oct 16 08:08:27 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step3. part 2 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: angry.png X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > I am having trouble appending my child processes pwd. I have created a file called > "stuff" and put another file called "more stuff" in it just to see if my process is > working. > > when I check my file name it prints ".../mysh/stuff", however when I call 'pwd' mysh > only prints out ".../mysh". > > I am using the following to change the directories: > > execvp(newpwd, t -> argv); > > where, newpwd = ".../mysh/stuff" > > Is the new path suppossed to be ".../mysh/stuff" when I call pwd, or is there > further stuff down the track in another step we must use to link pieces together. As > I have noticed that step 3 part 2 says "....,then mysh should *attempt* to change > from the current working (default) directory to the directory specified as the first > argument to the cd command." > > If anybody could shed some light on this, that would be great. > > Cheers, c",) I have tried to use chdir(newpwd), then execvp(newpwd, t -> argv) , still doesn't change the pwd !?! does anyone know what to do? Cheers. From 00014979@csse.uwa.edu.au Fri Oct 16 08:13:29 2015 Date: Fri Oct 16 08:13:29 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Can a successful solution only involve extending execute.c ? From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hi, can a successful solution only involve extending execute.c ? > (So, the program requirements can be met through only adding code to execute.c ?). It's *physically* possible to complete all project additions in a single file, though when you get to thinking about Step 9 you may decide to also modify mysh.c Whether it's a *good programming practice* to add everything to a single file is probably something you should also think about. From 00014979@csse.uwa.edu.au Fri Oct 16 08:21:05 2015 Date: Fri Oct 16 08:21:05 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Step3. part 2 From: "Christopher McDonald" X-smilie: none X-img: none Alot of your wording doesn't make sense, and it's unclear if that's affecting your thinking about it. > I am having trouble appending my child processes pwd. I have created a file called > "stuff" and put another file called "more stuff" in it just to see if my process is > working. Is "stuff" a file (as you say) or a directory? If you put "more stuff" in *it*, are you now saying that "stuff" is a directory? > when I check my file name it prints ".../mysh/stuff", however when I call 'pwd' mysh > only prints out ".../mysh". > > I am using the following to change the directories: > > execvp(newpwd, t -> argv); > > where, newpwd = ".../mysh/stuff" Then it's harder to follow. You do not change directories with an attempt to *overlay the current process with another program*. You certainly don't change directories by trying to execute a named directory. Investigate the system-call chdir(). From mcfald01@csse.uwa.edu.au Fri Oct 16 08:22:22 2015 Date: Fri Oct 16 08:22:22 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.169.137 Subject: IO redirection From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none I understand (at least in concept) how to use the io redirection 'functions' of bash, things like |, > and <, but I'm not entirely sure where they would be used, except if you were to read some kind of input from a file or output to a file. For example, my ls or cal functions aren't going to need any input aside from args (which I can't see coming from any of the other functions), CD might need a directory name but that's it. What kinds of 'functions' would utilize the input from another in this way? From 00014979@csse.uwa.edu.au Fri Oct 16 08:29:16 2015 Date: Fri Oct 16 08:29:16 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: IO redirection From: "Christopher McDonald" X-smilie: none X-img: none Let's not call then "functions", but programs - wc < textfile From mcfald01@csse.uwa.edu.au Fri Oct 16 08:29:52 2015 Date: Fri Oct 16 08:29:52 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.169.137 Subject: Simple commands From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none Which commands does this entitle? All the commands with/without arguments on this list? http://teaching.csse.uwa.edu.au/units/CITS2002/topcommands.php Or do we just do a call to already implemented commands (without needing to write them ourselves) Was a little confused here, thanks :) From lopasb03@csse.uwa.edu.au Fri Oct 16 08:34:50 2015 Date: Fri Oct 16 08:34:50 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step3. part 2 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > Alot of your wording doesn't make sense, and it's unclear if that's affecting your thinking > about it. > Yeah sorry about that, I realized after the hours editing time was up that my question wasn't as clear as it should have been. > > Is "stuff" a file (as you say) or a directory? "stuff" is a directory I have created, ie a folder within the pwd. > If you put "more stuff" in *it*, are you now saying that "stuff" is a directory? "more stuff" is just another folder within "stuff" to test my code. > > > when I check my file name it prints ".../mysh/stuff", however when I call 'pwd' mysh > > only prints out ".../mysh". > > > > I am using the following to change the directories: > > > > execvp(newpwd, t -> argv); > > > > where, newpwd = ".../mysh/stuff" > > Then it's harder to follow. > You do not change directories with an attempt to *overlay the current process with another > program*. So does this mean I should just attempt to chdir before I fork and create the new process? As I did with calling exit. > You certainly don't change directories by trying to execute a named directory. Sorry, I am still a little confused with it all. Does this mean I should not attempt to: execvp(newpwd, t -> argv); Does the first argument of execvp have to be an element within argv, not a manufactured directory? From 00014979@csse.uwa.edu.au Fri Oct 16 08:44:06 2015 Date: Fri Oct 16 08:44:06 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Step3. part 2 From: "Christopher McDonald" X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > So does this mean I should just attempt to chdir before I fork and create the new process? > As I did with calling exit. As the goal of the 'cd' command, like the 'exit' command, is to change something about the *current* process, then rethink why you're calling fork at all. What are you anticipating will need to be done in the new child process? From 00014979@csse.uwa.edu.au Fri Oct 16 08:46:18 2015 Date: Fri Oct 16 08:46:18 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Simple commands From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Which commands does this entitle? All the commands with/without arguments on this > list? All the above (and thousands more). > Or do we just do a call to already implemented commands (without needing to write them > ourselves) You do not need to write any of them, or any new ones; they all already exist on the disk (somewhere) and the role of mysh is to find them and execute them if requested. From mcfald01@csse.uwa.edu.au Fri Oct 16 08:54:48 2015 Date: Fri Oct 16 08:54:48 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.169.137 Subject: Simple commands From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none That makes it much clearer, thank you From lopasb03@csse.uwa.edu.au Fri Oct 16 09:40:17 2015 Date: Fri Oct 16 09:40:17 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step3. part 2 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > As the goal of the 'cd' command, like the 'exit' command, is to change something about the *current* process, > then rethink why you're calling fork at all. What are you anticipating will need to be done in the new child > process? OK, so now I'm a bit confused at what step 3 part 2 is actually asking us to do. I understand the following: When a new process gets created, its current directory is its *parent* process's current directory. A shell is just another *process*, no different from any other process, except that this particular process waits for you to type a command, then it executes the typed command as a *new* process. So when the step says mysh should *attempt* to change from the current working directory (which is the same as the parents current working directory) to the directory specified as the first argument to the cd command. Does this mean that our program should change the parents pwd, and hence our processes pwd? From 00014979@csse.uwa.edu.au Fri Oct 16 11:37:57 2015 Date: Fri Oct 16 11:37:57 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Step3. part 2 From: "Christopher McDonald" X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > OK, so now I'm a bit confused at what step 3 part 2 is actually asking us to do. I understand the following: Hi Ben, This sequence of questions is certainly relevant to the project step that you're addressing, but they're exactly the sort of questions that I'm hoping students will be discussing with their project partner (who is not me). Are you working with a project partner on these steps? From lopasb03@csse.uwa.edu.au Fri Oct 16 12:38:50 2015 Date: Fri Oct 16 12:38:50 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step3. part 2 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: nerd.png X-img: none "Christopher McDonald" wrote: > "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > > > OK, so now I'm a bit confused at what step 3 part 2 is actually asking us to do. I understand the following: > > Hi Ben, > > This sequence of questions is certainly relevant to the project step that you're addressing, but they're exactly the sort of > questions that I'm hoping students will be discussing with their project partner (who is not me). > Are you working with a project partner on these steps? I have not had the chance to work with my project partner to date, he finishes a large third year ecoms project @ 5pm today, and tells me that he will then be able to help me solidly work on this project until it is completed. This is why I am posting a lot of questions on the forum, because when I get stuck, I have had no-one to discuss the problem with. Hopefully after 5 pm today I can get some help and will therefore not be posting a large amount of questions on this forum. To refer to my previous question basically I need to know that if I say in my shell "cd stuff", then call 'pwd' should the new directory be "..../mysh/stuff" , that is basically all I need to know for now. In the future I will try to limit my questions and hopefully be able to get help through discussion with my project partner. Thanks, Ben. c",) From 00014979@csse.uwa.edu.au Fri Oct 16 13:04:00 2015 Date: Fri Oct 16 13:04:00 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Step3. part 2 From: "Christopher McDonald" X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > To refer to my previous question basically I need to know that if I say in my shell "cd stuff", then call 'pwd' should the new > directory be "..../mysh/stuff" , that is basically all I need to know for now. In the future I will try to limit my questions and > hopefully be able to get help through discussion with my project partner. OK; what does the standard shell do when you enter that command sequence? We're implementing only a small subset of the standard shell(s), but the parts we're implementing are very faithful to the way the standard shells work. From birdul01@csse.uwa.edu.au Fri Oct 16 14:13:59 2015 Date: Fri Oct 16 14:13:59 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.254.66 Subject: requirement to produce different makefile From: "Lena Birdus" <20925109@student.uwa.edu.au> X-smilie: none X-img: none Are we required to produce a different makefile to the one explained in the lectures? I understand that makefiles work on a fairly rigid structure, so it would be easy to use the one presented in the lecture and modify it, however this seems like plagiarism. In the lecture notes it says "Fortunately, we rarely need to remember all of these patterns and variables, and generally just copy and modify existing Makefiles," which suggests we should be able to use the example. Cheers! From lopasb03@csse.uwa.edu.au Fri Oct 16 15:12:17 2015 Date: Fri Oct 16 15:12:17 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: String Concatenations From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Hi, I am having trouble being able to concatenate a '/' character with a string, for example "help", does anybody have a clue how to do this? The new string I would be looking for would be "/help" From 00014979@csse.uwa.edu.au Fri Oct 16 15:21:33 2015 Date: Fri Oct 16 15:21:33 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: requirement to produce different makefile From: "Christopher McDonald" X-smilie: none X-img: none "Lena Birdus" <20925109@student.uwa.edu.au> wrote: > In the lecture notes it says "Fortunately, we rarely need to remember all of these patterns > and variables, and generally just copy and modify existing Makefiles," which suggests we > should be able to use the example. Indeed - no point reinventing the wheel, provided that it works and that you understand it (you could reproduce it)! From fetzee01@csse.uwa.edu.au Fri Oct 16 16:00:27 2015 Date: Fri Oct 16 16:00:27 2015 To: help2002@csse.uwa.edu.au Received: from 122.111.245.242 Subject: String Concatenations From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > Hi, I am having trouble being able to concatenate a '/' character with a string, for > example "help", does anybody have a clue how to do this? > > The new string I would be looking for would be "/help" Do you mean the help unix command? From lopasb03@csse.uwa.edu.au Fri Oct 16 16:03:42 2015 Date: Fri Oct 16 16:03:42 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: String Concatenations From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none it doesn't have to be "help" it could be any string like "hey", I can't find a way to concatenate '/' and "hey" so that the new string is "/hey" ? From newmal01@csse.uwa.edu.au Fri Oct 16 16:22:10 2015 Date: Fri Oct 16 16:22:10 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: Project Marks From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none Hi was just wondering if the project 1 marks will be realeased soon, i understand that it takes along time to automatically and manually mark each assignment? From newmal01@csse.uwa.edu.au Fri Oct 16 19:03:58 2015 Date: Fri Oct 16 19:03:58 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: expected feature From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none what are the expected commands we are suposed to implement for the bash shell From newmal01@csse.uwa.edu.au Fri Oct 16 19:42:35 2015 Date: Fri Oct 16 19:42:35 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: Up to date From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none Just a question that probably alot of other people are wondering will we be able to complete the project if e are not up to date with either labs, lecture, tutorials or all of the before mention? From mcfald01@csse.uwa.edu.au Fri Oct 16 20:01:19 2015 Date: Fri Oct 16 20:01:19 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.178.94 Subject: expected feature From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none All of them on that system I assume. One way to do it would be through system() call (not sure if we're allowed to use this or if there's a catch, it's pretty easy) or you could directly open the program with fork() and execv() That's my understanding, might be wrong. good luck :) From lopasb03@csse.uwa.edu.au Fri Oct 16 20:15:47 2015 Date: Fri Oct 16 20:15:47 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: String Concatenations From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Nevermind, I ended up figuring it out. Cheers. From nelsoj07@csse.uwa.edu.au Fri Oct 16 21:58:08 2015 Date: Fri Oct 16 21:58:08 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.224.251 Subject: expected feature From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none To answer anonymous question, we are only required to recreate very specific commands from scratch, given in step 3. The rest of the time, you are just looking for the requested program in the directories specified by the path variable, or the exact full path typed. So typing in: prompt> ls should look for a program named ls and execute it, and on most systems will find it. However equally valid would be typing in: prompt> batman and would be asking the shell to look for a program named batman, but this would fail on most systems and do nothing. If I did have a program named batman in the directory /home/alfred/ then typing in the below: prompt> /home/alfred/batman would run whatever program this is. Long day so sorry if that doesn't help! Daniel from speaking to Chris at the lecture on Thursday, system() is effectively cheating. Paraphrasing from the man page for system() that I found here http://linux.die.net/man/3/system, system works by executing a command specified by calling /bin/sh -c command, and returns after the command has been completed. Since it effectively just uses the existing shell, then it doesn't match the requirements of the project. I might not be 100% correct on this, but that's my understanding of it! From lis63@csse.uwa.edu.au Fri Oct 16 23:05:12 2015 Date: Fri Oct 16 23:05:12 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.221.171 Subject: a question on life time of a variable. From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none I remember that when a call of a function is finished, the memory of the function will be freed. And I try following code: char* f2(){ char* a_f2= "hello"; return a_f2; } char* f1(){ char* a_f1=f2(); return a_f1; } int main(){ char* a= strdup(f1()); printf("%s\n",a); return 0; } the output is: hello I think when main() calls f1(), f2() is finished and the memory of a_f2 is freed. So I don't know why my code runs successfully. Is it safe to write code like this? From lis63@csse.uwa.edu.au Fri Oct 16 23:12:25 2015 Date: Fri Oct 16 23:12:25 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.221.171 Subject: a question on life time of a variable. From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none I test following code: char* f2(){ char a_f2[]= "hello"; return a_f2; } There is a warning "function returns address of local variable". So it seems more strange to me. Why I can return a local pointer but not a local array? From bradfj01@csse.uwa.edu.au Fri Oct 16 23:15:50 2015 Date: Fri Oct 16 23:15:50 2015 To: help2002@csse.uwa.edu.au Received: from 60.224.9.24 Subject: Step 1 confusion From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none Hi everyone, I'm still quite confused with execv. I understand it takes two parameters - path name, and a vector ending with a NULL. The question on my mind is on how to extract the arguments and pathname, I was thinking of theCMDTREE structure already having the stdin, but considering if I call /bin/ls, what should I put for the vector if that's the only input? Should it just be - {"/bin/ls", NULL}? From lis63@csse.uwa.edu.au Sat Oct 17 00:26:59 2015 Date: Sat Oct 17 00:26:59 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.221.171 Subject: Step 1 confusion From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > Hi everyone, I'm still quite confused with execv. I understand it takes two parameters - > path name, and a vector ending with a NULL. The question on my mind is on how to extract > the arguments and pathname, I was thinking of theCMDTREE structure already having the > stdin, but considering if I call /bin/ls, what should I put for the vector if that's the > only input? Should it just be - {"/bin/ls", NULL}? Yes,if input is /bin/ls, my code will be like evecv("/bin/ls",arg)//where arg={"/bin/ls", NULL} and it works From lis63@csse.uwa.edu.au Sat Oct 17 00:35:25 2015 Date: Sat Oct 17 00:35:25 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.221.171 Subject: question on step3.part1 From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none It says "When requested without any arguments, the exit-status of the recently executed command should be used. " So what is the "the exit-status of the recently executed command"?What if the user just input "exit" and no other command has been executed? Besides,I use kill()to kill parent process in a child process, is it OK? From bradfj01@csse.uwa.edu.au Sat Oct 17 01:06:34 2015 Date: Sat Oct 17 01:06:34 2015 To: help2002@csse.uwa.edu.au Received: from 60.224.9.24 Subject: Step 1 confusion From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > ANONYMOUS wrote: > > > Hi everyone, I'm still quite confused with execv. I understand it takes two parameters - > > path name, and a vector ending with a NULL. The question on my mind is on how to extract > > the arguments and pathname, I was thinking of theCMDTREE structure already having the > > stdin, but considering if I call /bin/ls, what should I put for the vector if that's the > > only input? Should it just be - {"/bin/ls", NULL}? > > Yes,if input is /bin/ls, my code will be like > > evecv("/bin/ls",arg)//where arg={"/bin/ls", NULL} > > and it works Ahh I see, thank you very much :) From 00014979@csse.uwa.edu.au Sat Oct 17 07:48:49 2015 Date: Sat Oct 17 07:48:49 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Up to date From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Just a question that probably alot of other people are wondering will we be able to > complete the project if e are not up to date with either labs, lecture, tutorials or > all of the before mention? Not really sure how to answer this question; completing the lab exercises and revising through tutorials provides both the knowledge and the confidence to apply the same in different exercises (such as the project). While you can obviously cut-and-paste from the sample solutions that you believe are relevant, I believe you'd have learnt the material better by 'suffering' through having developed it yourself. But that could head off to more philosophical discussion about why students attend uni. So what answer are you seeking? Yes, by devoting more time to the CITS2002 now, rather than over the preceding weeks, you'll probably be able to complete the project. How much more time will obviously depend on an individual's ability, other studies and deadlines, and whether they're 'lucky' in quickly identifying material helpful for the project, and not too much other material that's not required. But, for most students, this is a unit at the end of their 2nd year, so I know I've not described anything newsworthy. From 00014979@csse.uwa.edu.au Sat Oct 17 07:53:24 2015 Date: Sat Oct 17 07:53:24 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: expected feature From: "Christopher McDonald" X-smilie: none X-img: none "Daniel Mcfall" <21312007@student.uwa.edu.au> wrote: > One way to do it would be through system() call (not sure if we're allowed to use this > or if there's a catch, it's pretty easy) As Jake has stated, no, don't use the system() function. Here's much, but not all, of the project written using system() : int main(int argc, char *argv[]) { char line[BUFSIZ]; int status = 0; printf("prompt> "); while(fgets(line, sizeof line, stdin) != NULL) { status = system(line); printf("prompt> "); } return status; } Now, what have you learnt about Programming and Systems by 'implementing' that? From 00014979@csse.uwa.edu.au Sat Oct 17 07:58:00 2015 Date: Sat Oct 17 07:58:00 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: a question on life time of a variable. From: "Christopher McDonald" X-smilie: none X-img: none "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > I think when main() calls f1(), f2() is finished and the memory of a_f2 is freed. > So I don't know why my code runs successfully. Is it safe to write code like this? Yes, it's safe; Your code is not using the local variables that once existed when their functions were running, but you're using the *value* of those variables, which is a pointer pointing memory allocated on the (persistent) heap, when you called strdup(). From 00014979@csse.uwa.edu.au Sat Oct 17 07:59:59 2015 Date: Sat Oct 17 07:59:59 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: a question on life time of a variable. From: "Christopher McDonald" X-smilie: none X-img: none "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > I test following code: > > char* f2(){ > char a_f2[]= "hello"; > return a_f2; > } > > There is a warning "function returns address of local variable". > So it seems more strange to me. Why I can return a local pointer but not a local array? You're not "returning a local pointer", but are returning the *value* that that pointer held. For the same reason that this works: int func(void) { int local = 3; return local; } From 00014979@csse.uwa.edu.au Sat Oct 17 08:41:30 2015 Date: Sat Oct 17 08:41:30 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: question on step3.part1 From: "Christopher McDonald" X-smilie: none X-img: none "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > It says "When requested without any arguments, the exit-status of the recently > executed command should be used. " > > So what is the "the exit-status of the recently executed command"?What if the user > just input "exit" and no other command has been executed? Your parent processes are informed of how their child processes exited when the parent calls wait (or maybe waitpid). From your standard shell, try: sh -c "exit" ; echo $status and sh -c "exit 3" ; echo $status > Besides,I use kill()to kill parent process in a child process, is it OK? You do not need/require a new child process to just kill its parent - the parent can terminate itself by calling exit() directly. From liaoj02@csse.uwa.edu.au Sat Oct 17 08:49:55 2015 Date: Sat Oct 17 08:49:55 2015 To: help2002@csse.uwa.edu.au Received: from 43.252.114.62 Subject: String Concatenations From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > Nevermind, I ended up figuring it out. Cheers. Hi man , did u use strcat? From fletca07@csse.uwa.edu.au Sat Oct 17 09:11:19 2015 Date: Sat Oct 17 09:11:19 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.64.208 Subject: Project 2 Partner From: "Alexander Fletcher" <21501626@student.uwa.edu.au> X-smilie: heart.png X-img: none Hey, I know it's really late but if anyone still needs a partner they can email me 21501626@student.uwa.edu.au :) From lopasb03@csse.uwa.edu.au Sat Oct 17 09:55:25 2015 Date: Sat Oct 17 09:55:25 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: String Concatenations From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > ANONYMOUS wrote: > > > Nevermind, I ended up figuring it out. Cheers. > > Hi man , did u use strcat? No, I wrote my own code using pointers. :) From lis63@csse.uwa.edu.au Sat Oct 17 11:25:46 2015 Date: Sat Oct 17 11:25:46 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.221.171 Subject: question on step3.part1 From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > > > It says "When requested without any arguments, the exit-status of the recently > > executed command should be used. " > > > > So what is the "the exit-status of the recently executed command"?What if the user > > just input "exit" and no other command has been executed? > > Your parent processes are informed of how their child processes exited when the parent calls > wait (or maybe waitpid). From your standard shell, try: > > sh -c "exit" ; echo $status > and > sh -c "exit 3" ; echo $status > > Besides,I use kill()to kill parent process in a child process, is it OK? > > You do not need/require a new child process to just kill its parent - the parent can > terminate itself by calling exit() directly. I see. Thank you. By the way, I find in linux "echo $status" doesn't work, but "echo $?" works. From lopasb03@csse.uwa.edu.au Sat Oct 17 12:27:16 2015 Date: Sat Oct 17 12:27:16 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step 4, Part 1, 2 and 3 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Hi, does anybody know how to go about implementing step 4, I'm a bit confused with how to implement it using the functions in the other files. Any help would be appreciated. Thanks. :) From newmal01@csse.uwa.edu.au Sat Oct 17 16:52:58 2015 Date: Sat Oct 17 16:52:58 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: Swap() From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none i dont understand this? When i pass the address of a variable to a function who argumets are pointers the address of the variable is not the same still? From lopasb03@csse.uwa.edu.au Sat Oct 17 19:14:05 2015 Date: Sat Oct 17 19:14:05 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step 4, Part 1, 2 and 3 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Nevermind, I figured most of it out, I just need to get the code right. :) From newmal01@csse.uwa.edu.au Sat Oct 17 20:21:50 2015 Date: Sat Oct 17 20:21:50 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: Project 2 Partner From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none anyone still looking for a partner ? 21107195@student.uwa.edu.au From newmal01@csse.uwa.edu.au Sat Oct 17 20:29:00 2015 Date: Sat Oct 17 20:29:00 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: command input From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none Im still not fully understanding the project? are we required to provide a command at the prompt or are we to use the stdin stream to enter a command From 00014979@csse.uwa.edu.au Sun Oct 18 08:11:26 2015 Date: Sun Oct 18 08:11:26 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: command input From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Im still not fully understanding the project? > are we required to provide a command at the prompt or are we to use the stdin stream > to enter a command The starting files, when compiled and linked, read their input from stdin, and don't care whether the stdin is coming from a keyboard, a redirected textfile, or a pipe: ./mysh # will just read from the keyboard ./mysh < fileofocmmands cat fileofcommands | ./mysh If the input happens to be coming from a keyboard (interactive input), the mysh parser also prints a prompt when it's ready to read its next line of input. ?? From 00014979@csse.uwa.edu.au Sun Oct 18 08:13:15 2015 Date: Sun Oct 18 08:13:15 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Swap() From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > i dont understand this? > > When i pass the address of a variable to a function who argumets are pointers > the address of the variable is not the same still? (confusing wording) No, passing the address of a variable to a function's parameter does not change the address of that variable. While a program is running, the physical location of variables never move. ?? From 00014979@csse.uwa.edu.au Sun Oct 18 08:15:35 2015 Date: Sun Oct 18 08:15:35 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: question on step3.part1 From: "Christopher McDonald" X-smilie: none X-img: none "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > By the way, I find in linux "echo $status" doesn't work, but "echo $?" works. Whether or not the value of $status is available will not be a property of either Linux, OS-X, or the operating system, but a property of which shell is being (different shells may support $status, or not). On each platform: echo $SHELL and I suspect you'll find them to be different. From liaoj02@csse.uwa.edu.au Sun Oct 18 09:25:37 2015 Date: Sun Oct 18 09:25:37 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.124.164 Subject: String Concatenations From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > ANONYMOUS wrote: > > > ANONYMOUS wrote: > > > > > Nevermind, I ended up figuring it out. Cheers. > > > > Hi man , did u use strcat? > > No, I wrote my own code using pointers. :) Umm, still using execv() for part 2? From khooe03@csse.uwa.edu.au Sun Oct 18 09:51:13 2015 Date: Sun Oct 18 09:51:13 2015 To: help2002@csse.uwa.edu.au Received: from 168.1.75.32 Subject: PATH and ls and cal commands From: "Elliot Khoo" <10421053@student.uwa.edu.au> X-smilie: none X-img: none Hi, From my understanding of how PATH works, I should no longer need any code for ls or cal functions. If i write a generalised function that correctly loops through all the PATH variables and calls execv correctly. My problem is that /bin/ and /usr/bin/ are not in my PATH values. Should I automatically search these directories? How does my normal shell do it? Thanks Elliot From newmal01@csse.uwa.edu.au Sun Oct 18 10:11:26 2015 Date: Sun Oct 18 10:11:26 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: execv() From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none i understand that the function execv() will execute a file i just dont understand the relationship (or need) for fork()? From newmal01@csse.uwa.edu.au Sun Oct 18 12:06:12 2015 Date: Sun Oct 18 12:06:12 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: STEP 2! From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none im just onder are we required to seperate the PATH at the ':' into seperate strings and test the command for each set of directories? From pratia02@csse.uwa.edu.au Sun Oct 18 12:56:21 2015 Date: Sun Oct 18 12:56:21 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.241.1 Subject: Project 2 partner From: "Aashay Pratish" <21424509@student.uwa.edu.au> X-smilie: none X-img: none Hey Everyone, I am looking for a partner for project 2! my email address is 21424509@student.uwa.edu.au Thanks, From lopasb03@csse.uwa.edu.au Sun Oct 18 13:37:46 2015 Date: Sun Oct 18 13:37:46 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: expected feature From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: bigsmile.png X-img: none "Christopher McDonald" wrote: > "Daniel Mcfall" <21312007@student.uwa.edu.au> wrote: > > > One way to do it would be through system() call (not sure if we're allowed to use this > > or if there's a catch, it's pretty easy) > > As Jake has stated, no, don't use the system() function. > Here's much, but not all, of the project written using system() : > > > Now, what have you learnt about Programming and Systems by 'implementing' that? I have done step 4, part 2 and 3 using the system() function, is that allowed? I couldn't seem to be able to implement them any other way, I mean I got close, but no cigar. I haven't read anywhere in the project specs that says we are not allowed to use the system() function at all. I tried to use popen() function, but that didn't work, so I resorted to system. All my code works correctly and I do use my execute_cmdtree in both of those functions, has anyone figured out how to do it without using system(), ie is there a better method or function that can be used. As far as I am aware system() and popen() are the only two functions in c that you can use to determine whether of not a command is successful? Any help/tips would be appreciated. Cheers, c",) From birdul01@csse.uwa.edu.au Sun Oct 18 15:27:47 2015 Date: Sun Oct 18 15:27:47 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.242.216 Subject: requirement to produce different makefile From: "Lena Birdus" <20925109@student.uwa.edu.au> X-smilie: none X-img: none Thanks for that! Makes sense. From lis63@csse.uwa.edu.au Sun Oct 18 15:29:40 2015 Date: Sun Oct 18 15:29:40 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.221.171 Subject: execv() From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > i understand that the function execv() will execute a file i just dont understand the > relationship (or need) for fork()? First, Use fork() to produce a child process, and the child process will use execv() to execute a file. Then, the parent process wait for the child process to exit. From jennib03@csse.uwa.edu.au Sun Oct 18 15:34:14 2015 Date: Sun Oct 18 15:34:14 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.70.72 Subject: A new Facebook ad. From: "Benjamin Jennings" <21460003@student.uwa.edu.au> X-smilie: none X-img: none Apparently Facebook knows I like IT. The horror. This popped up in an advert: http://info.varonis.com/cards-against-it There are some funny cards in there, but beware step 1. Also, they will probably spam you... I don't know if it was a one email type deal, so here is the direct link to the pack if you have no interest in DatAnywhere software: http://info.varonis.com/hubfs/cards-v1-1.pdf From lis63@csse.uwa.edu.au Sun Oct 18 15:36:36 2015 Date: Sun Oct 18 15:36:36 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.221.171 Subject: question on step3.part1 From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > > > By the way, I find in linux "echo $status" doesn't work, but "echo $?" works. > > Whether or not the value of $status is available will not be a property of either Linux, OS-X, or the > operating system, but a property of which shell is being (different shells may support $status, or not). > > On each platform: echo $SHELL > and I suspect you'll find them to be different. Thank you. I see. I'm using bash. From lis63@csse.uwa.edu.au Sun Oct 18 17:11:20 2015 Date: Sun Oct 18 17:11:20 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.221.171 Subject: Should we change the value of CDPATH? From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none In Q3.step 2, it's said that "If the user enters a directory-name which does not contain a '/' character, then the members of CDPATH are considered as directories to locate the required directory." However, if I type cd Desktop , a standard shell will search the current working directory. So the result is related to the current working directory. And in mysh, the result is related to CDPATH. So I appended the current working directory to CDPATH. Is it right? From 00014979@csse.uwa.edu.au Sun Oct 18 17:59:16 2015 Date: Sun Oct 18 17:59:16 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: PATH and ls and cal commands From: "Christopher McDonald" X-smilie: none X-img: none "Elliot Khoo" <10421053@student.uwa.edu.au> wrote: > Hi, > > From my understanding of how PATH works, I should no longer need any code for ls or cal > functions. If i write a generalised function that correctly loops through all the PATH > variables and calls execv correctly. My problem is that /bin/ and /usr/bin/ are not in my > PATH values. Should I automatically search these directories? How does my normal shell do > it? Hello Elliot, You should not require any special code for ls and cal anyway. They are mention in Step 1 only as the example of two simple commands that are specified/required by providing their absolute pathname (i.e. they don't require PATH). It's very unusual for even the default value of PATH, on any Unix-based system to not have /bin and /usr/bin in it! What is your value of PATH - echo $PATH ?? From 00014979@csse.uwa.edu.au Sun Oct 18 18:02:08 2015 Date: Sun Oct 18 18:02:08 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: expected feature From: "Christopher McDonald" X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > I have done step 4, part 2 and 3 using the system() function, is that allowed? I couldn't > seem to be able to implement them any other way, I mean I got close, but no cigar. Whoa! Don't use system() (or popen()). My comment above explains why, and it's in the Clarifications. > As far as I am aware system() and popen() are the only two functions in c that you can use to > determine whether of not a command is successful? You appear to have posted many questions here, not read the questions and answers of other students, and somehow managed to avoid the content of Lecture-12. From 00014979@csse.uwa.edu.au Sun Oct 18 18:05:45 2015 Date: Sun Oct 18 18:05:45 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: STEP 2! From: "Christopher McDonald" X-smilie: none X-img: none See here: https://secure.csse.uwa.edu.au/run/help2002?a=710&all=y5 From 00014979@csse.uwa.edu.au Sun Oct 18 18:08:01 2015 Date: Sun Oct 18 18:08:01 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Should we change the value of CDPATH? From: "Christopher McDonald" X-smilie: none X-img: none "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > In Q3.step 2, it's said that "If the user enters a directory-name which does not > contain a '/' character, then the members of CDPATH are considered as directories to > locate the required directory." > > However, if I type > > cd Desktop > > , a standard shell will search the current working directory. So the result is > related to the current working directory. > > And in mysh, the result is related to CDPATH. > > So I appended the current working directory to CDPATH. Is it right? The use of CDPATH is just like the use of PATH. If your standard shell finds executables in the current directory, it's because you have '.' in your PATH. Similarly, you can type cd ./Desktop or have '.' in your CDPATH. From lopasb03@csse.uwa.edu.au Sun Oct 18 18:26:07 2015 Date: Sun Oct 18 18:26:07 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step 5 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Hi, I'm a little bit confused as to whether what I have done for this step is correct. Basically in psuedo-code this is what I have done: exectute_cmdtree(left) && execute_cmdtree(right); will this line cause the two commands to execute asynchronously? I don't know how to test this, if anyone has any ideas or suggestions that would be appreciated. Cheers, Ben. c",) From lopasb03@csse.uwa.edu.au Sun Oct 18 18:57:46 2015 Date: Sun Oct 18 18:57:46 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: expected feature From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > > > I have done step 4, part 2 and 3 using the system() function, is that allowed? I couldn't > > seem to be able to implement them any other way, I mean I got close, but no cigar. > > Whoa! Don't use system() (or popen()). > My comment above explains why, and it's in the Clarifications. > I haven't used system() up until these two steps and I understand why you are not supposed to, but I've spent two days trying to write them without using system() or popen, and by calling my execute_command function, is this not the way to go about it? No - one else has written anything else on this forum that I can find about step 4 parts 2 and 3 that helps me, or maybe I'm just not getting it? > > > As far as I am aware system() and popen() are the only two functions in c that you can use to > > determine whether of not a command is successful? > > You appear to have posted many questions here, not read the questions and answers of other students, and > somehow managed to avoid the content of Lecture-12. I have read literally every post on this forum since the project opened, and posted many questions myself to try and get some back and fourth dialogue happenning, as I thought this was the point of having the forum, but so far not many other students have replied to my questions. I have read lecture 12 a few times, but there is no sound on the lecture recording so maybe I'm missing the point? From lopasb03@csse.uwa.edu.au Sun Oct 18 19:01:56 2015 Date: Sun Oct 18 19:01:56 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: String Concatenations From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none I have ended up using sprintf function to concatenate a lot of things in my code... c",) From lis63@csse.uwa.edu.au Sun Oct 18 19:09:06 2015 Date: Sun Oct 18 19:09:06 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.185.96 Subject: Should we change the value of CDPATH? From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > > > In Q3.step 2, it's said that "If the user enters a directory-name which does not > > contain a '/' character, then the members of CDPATH are considered as directories to > > locate the required directory." > > > > However, if I type > > > > cd Desktop > > > > , a standard shell will search the current working directory. So the result is > > related to the current working directory. > > > > And in mysh, the result is related to CDPATH. > > > > So I appended the current working directory to CDPATH. Is it right? > > > The use of CDPATH is just like the use of PATH. > > If your standard shell finds executables in the current directory, it's because you have '.' in > your PATH. > > Similarly, you can type cd ./Desktop or have '.' in your CDPATH. Thank you! I see. From newmal01@csse.uwa.edu.au Sun Oct 18 22:12:27 2015 Date: Sun Oct 18 22:12:27 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: enviromental variable From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none am i corrent in sayin that if the is no directory given in the command then we simply use the enviromental varable path and seach for the file within each directory which is seperated by colonS? From nelsoj07@csse.uwa.edu.au Sun Oct 18 22:26:36 2015 Date: Sun Oct 18 22:26:36 2015 To: help2002@csse.uwa.edu.au Received: from 58.167.252.160 Subject: Step 5 From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none I'm not up to this step myself but could you use the gettimeofday() call to check if they both are run at the same time? From nelsoj07@csse.uwa.edu.au Sun Oct 18 22:27:11 2015 Date: Sun Oct 18 22:27:11 2015 To: help2002@csse.uwa.edu.au Received: from 58.167.252.160 Subject: enviromental variable From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Correct, been asked on here a lot :) From nelsoj07@csse.uwa.edu.au Sun Oct 18 22:41:19 2015 Date: Sun Oct 18 22:41:19 2015 To: help2002@csse.uwa.edu.au Received: from 58.167.252.160 Subject: expected feature From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none > As far as I am aware system() and popen() are the only two functions in c that you can use to > determine whether of not a command is successful? This can be done by using fork(), execv() and the wait() commands together, and maybe others I'm not aware of myself. > I have read literally every post on this forum since the project opened, and posted many questions myself to > try and get some back and fourth dialogue happenning, as I thought this was the point of having the forum, > but so far not many other students have replied to my questions. I have read lecture 12 a few times, but > there is no sound on the lecture recording so maybe I'm missing the point? I'm a little behind on this project compared to the last one, so I'm sure that's why some of the students have not been as able to answer! Good luck with it all :) From tans121@csse.uwa.edu.au Mon Oct 19 00:36:21 2015 Date: Mon Oct 19 00:36:21 2015 To: help2002@csse.uwa.edu.au Received: from 58.111.96.15 Subject: Step 9 From: "Shao-Ming Tan" <20920822@student.uwa.edu.au> X-smilie: none X-img: none Confused about what we are supposed to do for step 9? Are we putting in say, a filename on on the command line and if execv fails, we assume it's a text file? And this text file contains something like ls ; cal -y cal and each line will be input to the ./mysh shell? From 00014979@csse.uwa.edu.au Mon Oct 19 05:46:16 2015 Date: Mon Oct 19 05:46:16 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Step 5 From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > exectute_cmdtree(left) && execute_cmdtree(right); No, the above C code does not cause any concurrent execution. '&&' is C's Boolean conjunction operator (pronounced 'and') - if its left-hand expression is true (non-zero) then its right-hand expression will be evaluated. This really has nothing to do with Step 5, but it very similar to the correct execution of Step 4 part 2. From 00014979@csse.uwa.edu.au Mon Oct 19 06:12:04 2015 Date: Mon Oct 19 06:12:04 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: expected feature From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > I haven't used system() up until these two steps and I understand why you are not supposed to, but I've spent > two days trying to write them without using system() or popen, and by calling my execute_command function, is The structure of all 3 parts of Step 4 are identical other than for 1 or 2 lines. When you look at the 'physical' structure of all three cases using https://secure.csse.uwa.edu.au/run/cmdtree you'll see that they're identical, except for their operator. They also have the same shape when you request multiple identical operators, such as prog1 ; prog2 ; prog3 and prog1 && prog2 && prog3 If you're understanding and correctly executing part 1 without using system(), then you won't need it for parts 2 or 3, either. > I have read literally every post on this forum since the project opened, and posted many questions myself to > try and get some back and fourth dialogue happenning, as I thought this was the point of having the forum, Yes, I sympathise with you there; the level of engagement of our 170+ students, through lectures, and participation on the forum with only about 6 people contributing, is very disappointing. I can't explain it, but fear that it's the future. From 00014979@csse.uwa.edu.au Mon Oct 19 07:16:47 2015 Date: Mon Oct 19 07:16:47 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Step 9 From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Are we putting in say, a filename on on the command line and if execv fails, we assume > it's a text file? > > And this text file contains something like > ls ; cal -y > cal > and each line will be input to the ./mysh shell? I can't distinguish your wording from that of the project sheet (just paraphrasing?). Construct for yourself a simple experiment with a shellscript (a textfile containing shell commands), and see how your standard shell executes it (or not). From 00014979@csse.uwa.edu.au Mon Oct 19 15:29:06 2015 Date: Mon Oct 19 15:29:06 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Lecture on Tues 20th October - 2nd project tutorial From: "Christopher McDonald" X-smilie: none X-img: none X-announcefor: 36h Hello Everyone, I’m very concerned about the volume and depth of questions on our help2002 forum, and the many individual emails that I’m receiving, regarding the 2nd project. It may be just me being overly concerned, and maybe 100+ students can successfully ramp up their project efforts in the last week - but I suspect not. So something is clearly amiss. In tomorrow's normal lecture time, Tues 20th Oct, we’ll hold a tutorial-like session on the 2nd project, hopefully benefitting all those asking “Help! Where do I start with Step 1, 2, 3….?” I’ll happily answer any *specific* questions that you have, give a small coded example if it’ll help to better explain anything, but not give away big pieces of code after the Lecture. The unit’s Schedule webpage has been updated to reflect this, and it’s now complete for 2015, identifying all examinable material. From graven01@csse.uwa.edu.au Mon Oct 19 15:39:56 2015 Date: Mon Oct 19 15:39:56 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.23.162 Subject: Tutorial type lecture. From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none Chris this would be immensely helpful. thank you, my only concern is that i won't ask questions out of fear of feeling stupid, because its probably something that I've missed, i.e. something you've answered several times (perhaps getting frustrated with the same question), i.e. its hard to be anonymous in public. Have you a plan for going through examples or is it only question based and we will have to suck up our pride if we plan on getting answers to dumb questions? :D From 00014979@csse.uwa.edu.au Mon Oct 19 15:46:06 2015 Date: Mon Oct 19 15:46:06 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Tutorial type lecture. From: "Christopher McDonald" X-smilie: none X-img: none Just bring along your 'dumb' questions, and I'll do my best not to get frustrated(!) It's uni, we're adults, it's time to get over the need for anonymity. See you tomorrow. From liaoj02@csse.uwa.edu.au Mon Oct 19 16:19:56 2015 Date: Mon Oct 19 16:19:56 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.141 Subject: Should we change the value of CDPATH? From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > In Q3.step 2, it's said that "If the user enters a directory-name which does not > contain a '/' character, then the members of CDPATH are considered as directories to > locate the required directory." > > However, if I type > > cd Desktop > > , a standard shell will search the current working directory. So the result is > related to the current working directory. > > And in mysh, the result is related to CDPATH. > > So I appended the current working directory to CDPATH. Is it right? Hello. May I ask what should be the correct reference to the argument after "CD"? (e.g. cd /bin ) I try to use t->argv[1] to do it but it does not work Thanks From 00014979@csse.uwa.edu.au Mon Oct 19 16:23:10 2015 Date: Mon Oct 19 16:23:10 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Should we change the value of CDPATH? From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hello. May I ask what should be the correct reference to the argument after "CD"? (e.g. cd /bin > ) I try to use t->argv[1] to do it but it does not work That's what you'll see if you run https://secure.csse.uwa.edu.au/run/cmdtree (which uses exactly the same parser). What do you see? From liaoj02@csse.uwa.edu.au Mon Oct 19 16:46:44 2015 Date: Mon Oct 19 16:46:44 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.141 Subject: Should we change the value of CDPATH? From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none NVM. I just mixed up the condition in my code. It works now . THank you From zhangy56@csse.uwa.edu.au Mon Oct 19 17:01:53 2015 Date: Mon Oct 19 17:01:53 2015 To: help2002@csse.uwa.edu.au Received: from 180.216.60.20 Subject: parse_cmdtree(FILE* ) function From: "Yixin Zhang" <20866853@student.uwa.edu.au> X-smilie: none X-img: none My program only executes the first command I typed, except the internal commands like "exit""time". I guess that something wrong happens to the parsing? I put fgets(line, sizeof line, stdin); CMDTREE *parse_cmdtree(FILE * line); forkprocess(argv+1); in my main function. Can somebody help me? Thank you. here is my printout result: >ls waiting execute.c main3 mysh.h execute.o main3.c mysh.o globals.c makefile mysho.c globals.o mysh parser.c internal commands.c mysh.c parser.o child finished >cal (different command but same result) waiting execute.c main3 mysh.h execute.o main3.c mysh.o globals.c makefile mysho.c globals.o mysh parser.c internal commands.c mysh.c parser.o child finished > From 00014979@csse.uwa.edu.au Mon Oct 19 17:28:39 2015 Date: Mon Oct 19 17:28:39 2015 Edit: Mon Oct 19 18:04:17 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: parse_cmdtree(FILE* ) function From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > My program only executes the first command I typed, except the internal commands like > "exit""time". I guess that something wrong happens to the parsing? > > I put > > fgets(line, sizeof line, stdin); > CMDTREE *parse_cmdtree(FILE * line); > forkprocess(argv+1); I've no idea, from what you've provided. But what you've added is quite different to the working code provided in the starting materials, so I think it's too early to blame the parsing! The code you've provided reads a line from stdin, DOES NOT call parse_cmdtree(), and then calls a function you must have written, with an unknown argument. ?? From khooe03@csse.uwa.edu.au Mon Oct 19 17:38:08 2015 Date: Mon Oct 19 17:38:08 2015 To: help2002@csse.uwa.edu.au Received: from 58.179.213.254 Subject: PATH and ls and cal commands From: "Elliot Khoo" <10421053@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > "Elliot Khoo" <10421053@student.uwa.edu.au> wrote: > > > Hi, > > > > From my understanding of how PATH works, I should no longer need any code for ls or cal > > functions. If i write a generalised function that correctly loops through all the PATH > > variables and calls execv correctly. My problem is that /bin/ and /usr/bin/ are not in my > > PATH values. Should I automatically search these directories? How does my normal shell do > > it? > > Hello Elliot, > > You should not require any special code for ls and cal anyway. > They are mention in Step 1 only as the example of two simple commands that are specified/required by > providing their absolute pathname (i.e. they don't require PATH). > > It's very unusual for even the default value of PATH, on any Unix-based system to not have /bin and > /usr/bin in it! What is your value of PATH - echo $PATH > ?? Thanks Chris, I found a bug in the way i was splitting the string, I forgot to copy the null byte! From lopasb03@csse.uwa.edu.au Mon Oct 19 18:28:31 2015 Date: Mon Oct 19 18:28:31 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step 5 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none I am still trying to figure this part out and I have come up with a couple of possibilities, but I'm not sure if either of them are correct: int ret = exectute_cmdtree(left),execute_cmdtree(right); or maybe: int ret = exectute_cmdtree(left); ret = execute_cmdtree(right); If anyone knows how to go about this step, could you please send me in the right direction. :) From chinnd01@csse.uwa.edu.au Mon Oct 19 18:54:22 2015 Date: Mon Oct 19 18:54:22 2015 To: help2002@csse.uwa.edu.au Received: from 60.228.81.170 Subject: Step 5 From: "David Chinnery" <21142701@student.uwa.edu.au> X-smilie: none X-img: none Do you mean step 4.2? If you have done 4.1 then 4.2 is easy you just need to check the exitstatus of the left command. If it's successful run the right one. I hope :). That's what I did and compared with BASH and came up with the same result. Well it did at home anyway :) From lopasb03@csse.uwa.edu.au Mon Oct 19 19:20:45 2015 Date: Mon Oct 19 19:20:45 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step 5 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "David Chinnery" <21142701@student.uwa.edu.au> wrote: > Do you mean step 4.2? If you have done 4.1 then 4.2 is easy you just need to check the exitstatus of the left command. If it's successful run the right one. > I hope :). > That's what I did and compared with BASH and came up with the same result. Well it did at home anyway :) No I have done all of step 4, 4.1 is just,r = left side && right side, as for your comments about 4.2, yes, that is exactly what I have done. Although I suspect that step 5 is a little bit trickier than anything in step 4. I think it may be something along the lines of starting the left process the immediately forking off and running the right process. Although, I am not sure because i am using my execute_command function which creates a new process when the left command is tested, and also when the right command is tested, so I'm thinking it could be something as simple as: r = left,right; or, r = left; r = right; In pseudo code of course. LMK what you think. Cheers, c",) From chinnd01@csse.uwa.edu.au Mon Oct 19 20:10:06 2015 Date: Mon Oct 19 20:10:06 2015 To: help2002@csse.uwa.edu.au Received: from 60.228.81.170 Subject: Step 5 From: "David Chinnery" <21142701@student.uwa.edu.au> X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > "David Chinnery" <21142701@student.uwa.edu.au> wrote: > > > Do you mean step 4.2? If you have done 4.1 then 4.2 is easy you just need to check the exitstatus of the left command. If it's successful run the right one. > > I hope :). > > That's what I did and compared with BASH and came up with the same result. Well it did at home anyway :) > > No I have done all of step 4, 4.1 is just,r = left side && right side, as for your comments about 4.2, yes, that is exactly what I have done. Although I suspect > that step 5 is a little bit trickier than anything in step 4. I think it may be something along the lines of starting the left process the immediately forking > off and running the right process. > > Although, I am not sure because i am using my execute_command function which creates a new process when the left command is tested, and also when the right > command is tested, so I'm thinking it could be something as simple as: > > r = left,right; > > or, > > r = left; > r = right; > > In pseudo code of course. LMK what you think. Cheers, c",) Yeah not sure if it's right or not but I just forked off the left and don't wait for the process to exit just run the next (if there is one). for example I used xload & which gave a small window and because its running in the background it gave me back my command prompt. BASH also give back the job number, mine doesn't - yet. xload doesn't as its running in the foreground and has taken over mysh. From mcfald01@csse.uwa.edu.au Mon Oct 19 21:11:21 2015 Date: Mon Oct 19 21:11:21 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.178.94 Subject: execvp and path variable From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none Relating to setting and searching through the path variable execvp automatically does this in much the same way as is required through step 2. Are we allowed to use this or would it be considered *cheating* also, for step 10 we implement some way to change these variables. Would this be a modification to the internal version of path, or a means to update the system's path variable? thanks for the clarification From khooe03@csse.uwa.edu.au Tue Oct 20 07:17:18 2015 Date: Tue Oct 20 07:17:18 2015 To: help2002@csse.uwa.edu.au Received: from 58.179.213.254 Subject: Executing chdir from a child process From: "Elliot Khoo" <10421053@student.uwa.edu.au> X-smilie: none X-img: none Hi Chris When I call chdir from a child process, it changes the the working directory of the child process, but not of the parent. I'm curious that if chdir is system call, why does it not change the working directory for everything? Does the system maintain a working directory for all programs and processes? (obviously it maintains one for programs) For the project if i call pwd;pwd;pwd;cd ..;pwd from my shell, then when the thing returns I will be on the parent directory. When implementing this in our shell, it will mean that in step 4 I will need to pass the current working directory back to the parent from the child process. I plan to traverse the cmdtree using recursion. This seems a little complicated, am I missing a better design pattern? Thanks Elliot From 00014979@csse.uwa.edu.au Tue Oct 20 07:17:20 2015 Date: Tue Oct 20 07:17:20 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: execvp and path variable From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Relating to setting and searching through the path variable > > execvp automatically does this in much the same way as is required through step 2. Are > we allowed to use this or would it be considered *cheating* execvp and what our project achieve a similar result but do so in slightly different ways (execvp requires an environment variable, whereas our project uses one of our C variables). In the spirit of the project, don't use execvp() - and writing the 8 lines necessary will be good for the soul. > also, for step 10 we implement some way to change these variables. Would this be a > modification to the internal version of path, or a means to update the system's path > variable? Just to our C program's own variable (to match the above). --- Yes, it looks a bit stilted, but I've gone this way to (I hoped) to make the project easier. After you submit your project, add all the fantastic features you like! From 00014979@csse.uwa.edu.au Tue Oct 20 07:21:46 2015 Date: Tue Oct 20 07:21:46 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Executing chdir from a child process From: "Christopher McDonald" X-smilie: none X-img: none "Elliot Khoo" <10421053@student.uwa.edu.au> wrote: > Hi Chris > > When I call chdir from a child process, it changes the the working directory of the child > process, but not of the parent. I'm curious that if chdir is system call, why does it not > change the working directory for everything? Does the system maintain a working directory > for all programs and processes? (obviously it maintains one for programs) chdir(), if successful, only changes the directory of the calling process. You cannot change the directory of any other process, or pass anything other than an exit-status back to your parent (unless you 'cheat' by writing/reading to the file-system). Child processes *inherit* attributes from their parent, but parent processes can't be modified by their child processes. From khooe03@csse.uwa.edu.au Tue Oct 20 07:25:26 2015 Date: Tue Oct 20 07:25:26 2015 To: help2002@csse.uwa.edu.au Received: from 58.179.213.254 Subject: Executing chdir from a child process From: "Elliot Khoo" <10421053@student.uwa.edu.au> X-smilie: none X-img: none So does this mean I cannot parse the tree using recursion? Also I am researching pipes and plan to use that to parse information back to the parent, is this not going to work? From 00014979@csse.uwa.edu.au Tue Oct 20 07:29:12 2015 Date: Tue Oct 20 07:29:12 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Executing chdir from a child process From: "Christopher McDonald" X-smilie: none X-img: none "Elliot Khoo" <10421053@student.uwa.edu.au> wrote: > So does this mean I cannot parse the tree using recursion? Also I am researching pipes and plan to use that to parse > information back to the parent, is this not going to work? My code *parses* and builds the tree; your code *walks* the tree. There really is no information that needs to be passed from a child process back to its parent (other than its exit-status, which is delivered when the child calls exit). From khooe03@csse.uwa.edu.au Tue Oct 20 07:42:42 2015 Date: Tue Oct 20 07:42:42 2015 To: help2002@csse.uwa.edu.au Received: from 168.1.75.6 Subject: Executing chdir from a child process From: "Elliot Khoo" <10421053@student.uwa.edu.au> X-smilie: none X-img: none Sorry, I mean *pass* not *parse*. Ok thanks I will try something different. From zhangy56@csse.uwa.edu.au Tue Oct 20 12:18:28 2015 Date: Tue Oct 20 12:18:28 2015 To: help2002@csse.uwa.edu.au Received: from 180.216.60.20 Subject: parse_cmdtree(FILE* ) function From: "Yixin Zhang" <20866853@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > My program only executes the first command I typed, except the internal commands like > > "exit""time". I guess that something wrong happens to the parsing? > > > > I put > > > > fgets(line, sizeof line, stdin); > > CMDTREE *parse_cmdtree(FILE * line); > > forkprocess(argv+1); > > I've no idea, from what you've provided. > But what you've added is quite different to the working code provided in the starting materials, > so I think it's too early to blame the parsing! > > The code you've provided reads a line from stdin, DOES NOT call parse_cmdtree(), and then calls a function you > must have written, with an unknown argument. ?? I misunderstood this part. Problem solved. Thanks Chris. From 00014979@csse.uwa.edu.au Sun Oct 25 09:28:50 2015 Date: Sun Oct 25 09:28:50 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: 1st Project marks - ALL RESOLVED? From: "Christopher McDonald" X-smilie: none X-img: none X-announcefor: 1w I've now re-checked the projects of all students who emailed about their project's marks, and have replied to them by email. --------- If you submitted a project, then your mark should now be visible in csmarks along with a PDF feedback sheet (each team-member can access the same feedback sheet). - The average mark for ALL SUBMITTED projects now 23.7/40 (22.9/40 in 2014) - The average mark for the project was 21.6/40 Congratulations to the 26 students receiving 35/40 or higher. If your mark is not in csmarks (or states Not Submitted), check to ensure that your project submission is in cssubmit (also ask your project partner) and, if so, please tell me. I previously sent email to all students without a submission, so please check your email too. If your mark is much lower than you had anticipated, it may be for a number of reasons: - some submitted projects cannot be compiled, even after a reasonable number of changes by me to try to get them to compile. If it took me a few attempts to get your project to compile you will have lost a mark or two. - some projects appear to have ignored the program's first parameter, thus preventing them from opening the required text/data files while marking. If it was a simple change to correct this it was corrected for you. - some projects produce no valid output (lines commencing with a digit representing a time-of-day). The automated marking of the two output tests was quite forgiving, but it did have to _look_ like valid output. If you believe that a *VERY SMALL number of changes* to your project are likely to improve your mark by more than, say, 5 marks, and can justify why making those changes would be fair to all other students, please let me know, by the LAST DAY OF SEMESTER. And a big thanks to both Amar and JT for undertaking their parts of the marking so quickly and consistently. Slowness, all my fault. Good luck, From newmal01@csse.uwa.edu.au Tue Oct 20 16:35:12 2015 Date: Tue Oct 20 16:35:12 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: getting the exit status of recently executed command From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none im not sure what it really means in step 3 when the user enters exit with no arguments return the exit status of the recent command, does that mean the command enter before or the command exit ? From fetzee01@csse.uwa.edu.au Tue Oct 20 22:40:49 2015 Date: Tue Oct 20 22:40:49 2015 Edit: Tue Oct 20 22:41:26 2015 To: help2002@csse.uwa.edu.au Received: from 122.111.245.242 Subject: test program for testing against automated marking ? From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none Hi Chris, Will this project be partially automatically marked using an automated marker like the last one? If so, and even if not, will we be provided a test program so we can test it against our output? i.e. a copy of your sample solution mysh executable so we can pass commands to it and test it against ours. Thank you. From mcfald01@csse.uwa.edu.au Wed Oct 21 02:11:45 2015 Date: Wed Oct 21 02:11:45 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.178.94 Subject: test program for testing against automated marking ? From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none For similar questions, Chris has noted that our output should mimic your regular shell, so you can test it with that as a 'sample solution'. Hope that helps, good luck. From 00014979@csse.uwa.edu.au Wed Oct 21 05:13:52 2015 Date: Wed Oct 21 05:13:52 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: getting the exit status of recently executed command From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > im not sure what it really means in step 3 when the user enters exit with no > arguments return the exit status of the recent command, does that mean the command > enter before or the command exit ? Consider this sequence of commands: ls -l (successful) date now (unsuccessful) exit 2 With the above sequence, your mysh would exit with a status=2, but with: ls -l (successful) date now (unsuccessful) exit your mysh would exit with whatever was the exit status of the date command. From 00014979@csse.uwa.edu.au Wed Oct 21 05:17:08 2015 Date: Wed Oct 21 05:17:08 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: test program for testing against automated marking ? From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Will this project be partially automatically marked using an automated marker like the last > one? Not sure yet; in terms of the ratio of automatic .vs. effort-required-to-resolve-problems it may not be worth it. > If so, and even if not, will we be provided a test program so we can test it against our output? i.e. a > copy of your sample solution mysh executable so we can pass commands to it and test it against > ours. Yes (in a day or two, as soon as I complete this re-marking of the timed-out 1st projects). But the other reply is correct too - "What does your standard shell do?" From newmal01@csse.uwa.edu.au Wed Oct 21 17:25:43 2015 Date: Wed Oct 21 17:25:43 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: getting the exit status of recently executed command From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > im not sure what it really means in step 3 when the user enters exit with no > > arguments return the exit status of the recent command, does that mean the command > > enter before or the command exit ? > > Consider this sequence of commands: > > ls -l (successful) > date now (unsuccessful) > exit 2 > are these command enter one after each other or at the same time? From 00014979@csse.uwa.edu.au Wed Oct 21 20:08:58 2015 Date: Wed Oct 21 20:08:58 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: getting the exit status of recently executed command From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > are these command enter one after each other or at the same time? It doesn't matter; they could be entered one-per-line, each executed separately (but still sequentially), or they could be executed with: ls -l ; date now ; exit From newmal01@csse.uwa.edu.au Wed Oct 21 23:02:17 2015 Date: Wed Oct 21 23:02:17 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: execution time From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none just wondring what a valid time would be for execution of a command eg. time /bin/ls should it be simimlar to our result from the the usual bash shell or should it be longer? From leeb22@csse.uwa.edu.au Thu Oct 22 01:44:35 2015 Date: Thu Oct 22 01:44:35 2015 To: help2002@csse.uwa.edu.au Received: from 121.215.35.188 Subject: print_cmdtree() confusion From: "Brian Lee" <21492167@student.uwa.edu.au> X-smilie: none X-img: none After using t->argv[0] anywhere in the else statement portion of the execute_cmdtree() function, it stops the print_cmdtree(t) in the main function from working. For example, when i put "&&" into the command line, instead of printing " && " it gives me a segmentation fault or it just prints out the last command i used. I don't think I can do step 4 if the cmdtree doesn't split into left and right paths so does anyone know why using t->argv[0] stops the function from working? From 00014979@csse.uwa.edu.au Thu Oct 22 08:24:36 2015 Date: Thu Oct 22 08:24:36 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: execution time From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > just wondring what a valid time would be for execution of a command > eg. time /bin/ls Most commands run very quickly (and most of the apparent delay comes from the screen displaying results, and not the true command itself). So your time implementation probably keeps reporting very small values, if not zero. Give it a bigger trial with: time /bin/sleep 10 > should it be simimlar to our result from the the usual bash shell > or should it be longer? Should be very similar. One thing of note is that most (all?) standard shells implement 'time' as an internal command (as we should), but that there's also an external program /usr/bin/time (on OSX) that performs a similar role. But we don't want that one. ______ AND, note that with our 'stripped down' shell, that we're unable to time the execution of a subshell, as with: time (ls ; date) Standard shells can do this because time is recognised as a keyword by their parsers, and I wanted to keep our parser and CMDTREE as simple as possible. From 00014979@csse.uwa.edu.au Thu Oct 22 08:28:54 2015 Date: Thu Oct 22 08:28:54 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: print_cmdtree() confusion From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > After using t->argv[0] anywhere in the else statement portion of the execute_cmdtree() > function, it stops the print_cmdtree(t) in the main function from working. > > For example, when i put "&&" into the command line, instead of printing " && > " it gives me a segmentation fault or it just prints out the last command i used. > > I don't think I can do step 4 if the cmdtree doesn't split into left and right paths so > does anyone know why using t->argv[0] stops the function from working? It's unclear what you mean by "After using t->argv[0]". Using? While the parser is likely not very robust when handling all possible inputs, the starting files do correctly print: mysh.1 && called from mysh.c, main() line 44: && when calling print_cmdtree(), so it seems that you've broken something somewhere else. From chinnd01@csse.uwa.edu.au Thu Oct 22 13:34:43 2015 Date: Thu Oct 22 13:34:43 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.149.54 Subject: A distraction From: "David Chinnery" <21142701@student.uwa.edu.au> X-smilie: woot.png X-img: none here is something to test project 2. telnet towel.blinkenlights.nl or just use it as a distraction :) From nelsoj07@csse.uwa.edu.au Thu Oct 22 13:38:47 2015 Date: Thu Oct 22 13:38:47 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: A distraction From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Great test of the new shell functionality, highly approve. From weinej01@csse.uwa.edu.au Thu Oct 22 14:30:13 2015 Date: Thu Oct 22 14:30:13 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.146.157 Subject: cd help From: "Jake Weiner" <20749646@student.uwa.edu.au> X-smilie: none X-img: none we have somehow managed to get our cd documents (for example) working (pwd prints the correct directory) however for some reason on terminal it keeps printing out /usr/bin/cd: line 4: cd: documents: No such file or directory we are just a bit confused about how this is even possible? From 00014979@csse.uwa.edu.au Thu Oct 22 14:46:41 2015 Date: Thu Oct 22 14:46:41 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: cd help From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > /usr/bin/cd: line 4: cd: documents: No such file or directory Why are you even searching for the location of 'cd' using your search path? From leeb22@csse.uwa.edu.au Thu Oct 22 15:42:50 2015 Date: Thu Oct 22 15:42:50 2015 To: help2002@csse.uwa.edu.au Received: from 121.215.35.188 Subject: print_cmdtree() confusion From: "Brian Lee" <21492167@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > After using t->argv[0] anywhere in the else statement portion of the execute_cmdtree() > > function, it stops the print_cmdtree(t) in the main function from working. > > > > For example, when i put "&&" into the command line, instead of printing " && > > " it gives me a segmentation fault or it just prints out the last command i used. > > > > I don't think I can do step 4 if the cmdtree doesn't split into left and right paths so > > does anyone know why using t->argv[0] stops the function from working? > > It's unclear what you mean by "After using t->argv[0]". Using? > > While the parser is likely not very robust when handling all possible inputs, the starting files do > correctly print: > > mysh.1 && > called from mysh.c, main() line 44: > && > > when calling print_cmdtree(), so it seems that you've broken something somewhere else. okay thanks. I worked out where my code went wrong. From liaoj02@csse.uwa.edu.au Thu Oct 22 16:15:16 2015 Date: Thu Oct 22 16:15:16 2015 Edit: Thu Oct 22 17:07:53 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.116 Subject: Calling each step seperately From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Hello. After discussion with my partner, We think making each step into a function then execute them according to the CMD command is better than putting all the possible cases in one function (execute_cmdtree()). I have a prototype like this void step1 (CMDTREE *t) { int pid; int exitstatus; switch (pid = fork()) { case -1 : .... case 0:// new child process execv(t->argv[0],argv); exit(EXIT_FAILURE); default: // original parent process .... } } execute_cmdtree(CMDTREE *t) { step(t->argv[0]); } Just wondering if thats the right sort of approach? Even though The CMDTREE command is not passed into the step1() due to type difference. (HOW to solve this problem ?As both function relies on input argument to execute.) Thanks From mcfald01@csse.uwa.edu.au Thu Oct 22 16:58:53 2015 Date: Thu Oct 22 16:58:53 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.175.211 Subject: Calling each step seperately From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none This makes the assumption that all of the steps can be implemented nicely by themselves in isolation. In practice, certain things such as traversing the tree or executing internal commands would take priority over just directly attempting to open everything externally before moving on. For example, if the top of the tree is an N_AND type, the program shouldn't try to apply step1 to it, but rather attempt to traverse it's left side and then do something based on whether that was successful or not. Breaking it into seperate functions (or even better, different files) is definitely the way to go, but in my eyes more complexity is needed than simply applying the steps to the tree in order. Hope that helps, good luck From liaoj02@csse.uwa.edu.au Thu Oct 22 17:12:29 2015 Date: Thu Oct 22 17:12:29 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.116 Subject: Calling each step seperately From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Thanks mate. However as both of my function depends on input arguments to run, it seems that the t- >argv[0] in step1() is not correct, because the arguments are passed as a string after receiving from the executeCMD . I wonder how can I get through this? CHeers. From mcfald01@csse.uwa.edu.au Thu Oct 22 18:34:22 2015 Date: Thu Oct 22 18:34:22 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.175.211 Subject: Calling each step seperately From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none I'm not sure what you mean by that You are passing a pointer to a string when the function requires you to pass a pointer to a CMDTREE From birdul01@csse.uwa.edu.au Thu Oct 22 20:46:34 2015 Date: Thu Oct 22 20:46:34 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.139 Subject: Part 3: Accessing the exit status of previous command for Exit From: "Lena Birdus" <20925109@student.uwa.edu.au> X-smilie: none X-img: none Hello, We are having trouble with Step 3, in particular the case where you exit with no argument and "the exit-status of the recently executed command should be used." In order to do this, we need the exit status of the mysh function (not the exit status of execute_cmdtree). We are not sure how to access this. What we have considered is: - Passing the exit status to the execute_cmdtree function as an additional argument. Is this a bad idea because we are deviating from the code structure given to us? - Exit from inside the mysh function, however this doesn't seem to fit elegantly with the structure of the code (commands are processed in the execute_cmdtree function) - Creating a global variable to store the previous exit status of the mysh function so it can be accessed from inside execute_cmdtree. We have tried this in many different ways, but it fails to link. The compiling works, but the linker doesn't. The output is shown below. We have seen a number of different versions of this error messages saying the linking failed in either the execute.o or mysh.o. We even tried copying and pasting the current extern variable definitions with different names and these won't link! Undefined symbols for architecture x86_64: "previousexitstatus", referenced from: _execute_cmdtree in execute.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [mysh] Error 1 Any suggestions for a better way to go about this? Thanks in advance! From mcfald01@csse.uwa.edu.au Thu Oct 22 21:26:04 2015 Date: Thu Oct 22 21:26:04 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.175.211 Subject: Part 3: Accessing the exit status of previous command for Exit From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none Hey, As much as I hate using global variables, that was the only way I could manage to make it work. It did work fine for me though, I just defined it in my execute.c file and had no problems. Perhaps there is another way aside from passing the exitstatus to the function that you call exit() from (and all the functions above it), which would be to return a specific number back to mysh.c which calls exit from there (with the exitstatus in scope). Whether this is more elegant I don't know, but it would require some modification to mysh. From newmal01@csse.uwa.edu.au Thu Oct 22 21:39:05 2015 Date: Thu Oct 22 21:39:05 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: print_cmdtree() confusion From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > okay thanks. I worked out where my code went wrong. hey mate ive got the same porblem where did you go wrong in your code originally? From leeb22@csse.uwa.edu.au Fri Oct 23 00:45:31 2015 Date: Fri Oct 23 00:45:31 2015 To: help2002@csse.uwa.edu.au Received: from 121.215.35.188 Subject: print_cmdtree() confusion From: "Brian Lee" <21492167@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > ANONYMOUS wrote: > > > > okay thanks. I worked out where my code went wrong. > > hey mate ive got the same porblem where did you go wrong in your code originally? It wasn't wrong exactly. I just needed to insert if statements to check whether or not the input entered in the command line was a simple command(N_COMMAND) or whether it had another specific set of symbols(such as && or || or ;) From newmal01@csse.uwa.edu.au Fri Oct 23 02:24:31 2015 Date: Fri Oct 23 02:24:31 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: project 2 material covered? From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none does project 2 cover the material from the start to week 11 only? From abusha02@csse.uwa.edu.au Fri Oct 23 04:32:54 2015 Date: Fri Oct 23 04:32:54 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.208.65 Subject: Part 3: Accessing the exit status of previous command for Exit From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none Odd. I was thinking about this in a different way. Since the step said 'recently executed command,' I thought it could be the previous command in the same tree. i.e. cal 2015 ##One command cal ; pwd; exit ##A series of three commands, but all stored in one command tree What I thought you'd be after in this case is the exit status of 'pwd.' With your approach, you'd instead be using the exit status of the first 'cal 2015', would you not? Maybe Chris could clarify what he means by 'recently executed command.' Does this mean the most recently executed command, or the most recently executed command tree? In the first case, you'll find it much easier to exit from within execute_cmdtree(). In the second case, it'd probably be easier to exit from within mysh. In the case of the most recently executed command (i.e. in the above example returning the exit status of 'pwd', not the 'cal 2015'), I think it'd be easier to exit from within execute_cmdtree(). This is because if you get something like: cal 2015; exit; pwd; cal You can just terminate with the right exit status as soon as you hit 'exit,' and ignore the rest. If you instead opted to terminate from within mysh whenever 'exit' is called, you'd need to pass control back to mysh first, and somehow tell mysh to call exit(). Much cleaner to simply do so from within execute_cmdtree(), as I'm understanding it. Either way, I think it best to see what Chris has to say regarding this. From 00014979@csse.uwa.edu.au Fri Oct 23 05:32:50 2015 Date: Fri Oct 23 05:32:50 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Part 3: Accessing the exit status of previous command for Exit From: "Christopher McDonald" X-smilie: none X-img: none Also discussed over here, with an almost identical title: https://secure.csse.uwa.edu.au/run/help2002?p=np&a=817&all=y4 I'm unsure how to paraphrase it more clearly - the most recently executed command is the one that just completed (in time), except that we ignore the status of any terminating backgrounded commands. From 00014979@csse.uwa.edu.au Fri Oct 23 05:35:08 2015 Date: Fri Oct 23 05:35:08 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: project 2 material covered? From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > does project 2 cover the material from the start to week 11 only? No; as discussed in Tuesday's lecture, you'll also need to learn new knowledge, best obtained by reading online documentation for the functions and system calls identified at the foot of Step. From 00014979@csse.uwa.edu.au Fri Oct 23 07:06:58 2015 Date: Fri Oct 23 07:06:58 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Part 3: Accessing the exit status of previous command for Exit From: "Christopher McDonald" X-smilie: none X-img: none "Lena Birdus" <20925109@student.uwa.edu.au> wrote: > - Passing the exit status to the execute_cmdtree function as an additional argument. Is > this a bad idea because we are deviating from the code structure given to us? You're welcome to change the starting code in any way that you wish - modifying the header file (though not CMDTREE), adding function parameters, adding functions, adding additional files. You're only strongly discouraged from changing the parser (which you won't need to for the required steps). > - Exit from inside the mysh function, however this doesn't seem to fit elegantly with the > structure of the code (commands are processed in the execute_cmdtree function) If you can determine that it's feasible to exit "right now", it's reasonable to call exit() right now; you don't have to return through all previous functions, and finally back to main(), to eventually return from main(). > - Creating a global variable to store the previous exit status of the mysh function so it > can be accessed from inside execute_cmdtree. We have tried this in many different ways, but > it fails to link. The compiling works, but the linker doesn't. The output is shown below. This seems just a 'standard' problem, not specific to the project. Exactly one .c file will need to define the variable, and other .c files needing to read/write the variable declare it as an external variable. If > 1 file needs the external declaration, it's easiest (here) to place a single external declaration in a common header file. Then make clean ; make From birdul01@csse.uwa.edu.au Fri Oct 23 14:06:37 2015 Date: Fri Oct 23 14:06:37 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.128 Subject: Part 3: Accessing the exit status of previous command for Exit From: "Lena Birdus" <20925109@student.uwa.edu.au> X-smilie: none X-img: none Hi Chris, Thanks very much for all that clarification. I found the problem with the code for the global variable. I must have checked it 20 times yesterday, and the problem stayed hidden, but as soon as I looked at it with fresh eyes it was obvious! Appreciate the help! From birdul01@csse.uwa.edu.au Fri Oct 23 14:10:57 2015 Date: Fri Oct 23 14:10:57 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.128 Subject: Part 3: Accessing the exit status of previous command for Exit From: "Lena Birdus" <20925109@student.uwa.edu.au> X-smilie: none X-img: none Ammar, I think the way to go is to exit from inside execute_commandtree, but I do think you need to use a global variable, because each invocation of execute_commandtree does not know about the previous invocation (but the exit status variable in mysh does). Daniel, thanks for your help! We've gotten it to work the same way as you I think! From abusha02@csse.uwa.edu.au Fri Oct 23 15:22:47 2015 Date: Fri Oct 23 15:22:47 2015 To: help2002@csse.uwa.edu.au Received: from 180.216.50.90 Subject: Part 3: Accessing the exit status of previous command for Exit From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none "Lena Birdus" <20925109@student.uwa.edu.au> wrote: > Ammar, I think the way to go is to exit from inside execute_commandtree, but I do think you need to use a global variable, > because each invocation of execute_commandtree does not know about the previous invocation (but the exit status variable in mysh > does). > > Daniel, thanks for your help! We've gotten it to work the same way as you I think! I agree. That's exactly the way I did it as well (with a global variable, from within execute_cmdtree) From graven01@csse.uwa.edu.au Fri Oct 23 16:54:56 2015 Date: Fri Oct 23 16:54:56 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Q3 part 2 From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none "If the name of the command to be executed is cd, then mysh should attempt to change from the current working (default) directory to the directory specified as the first argument to the cd command. If the command cd is given without arguments, then the variable HOME should be used as the new directory." is it expected to work as BASH , ie consider I'm in /User/Documents in ./mysh i type cd /User/Documents/MYFOLDER it will change However if i was in the same directory and just type in cd MYFOLDER it won't change, Do i have to (append (Depend??? ) to the start of the cd command my pwd ? just for clarification perhaps as the amount of time it took me to think and ask this question i could have just done it. :( From lopasb03@csse.uwa.edu.au Fri Oct 23 17:39:27 2015 Date: Fri Oct 23 17:39:27 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step 6 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Hi, I am having trouble working out if I have done step 6 correctly. What I have done if firstly call fork and name this fork as my child fork. If the fork is successful I then execute the commands inside the subshell. It is my understanding that when I call fork, we are forking off mysh and creating a child fork that has all the same attributes as the parent fork(mysh), so my above method should satisfy the specification of forking a copy of mysh to execute the commands. If anyone knows if this is the correct way to implement this could you please let me know, otherwise could you please point me in the right direction. Thanks, much appreciated. :) From lopasb03@csse.uwa.edu.au Fri Oct 23 19:47:40 2015 Date: Fri Oct 23 19:47:40 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step 7, part 1 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Hi, I am having trouble understanding what this step is supposed to do? How I see it, is that when execute_command recognises that the cmd line input is of the infile type, (ie. command < infile), then we are supposed to read the commands from the text file or similar, and then use those commands as the command we execute. For example, if we type date < infile, my program will open the file named 'infile', which in this case is infile.txt, then it will read the commands, in my case it is "usr/bin/cal -y", then mysh should execute those commands and not even execute the "date" command at the prompt. Is this correct, or have I got it completely back-to-front? Any help/comments or suggestions would be appreciated. Cheers, c",) From mcfald01@csse.uwa.edu.au Fri Oct 23 23:28:47 2015 Date: Fri Oct 23 23:28:47 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.175.211 Subject: Step 7, part 1 From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none a < b will execute a with the input of file b (instead of stdin) for example, make a text file and type "hello". You can do this by doing: echo "hello" > hello.txt then type the command tr a-z A-Z < hello.txt this will output HELLO (or whatever was in the file, in caps) To implement this you will need to redirect the stdin and stdout streams. Hope this helps, good luck From mcfald01@csse.uwa.edu.au Fri Oct 23 23:35:15 2015 Date: Fri Oct 23 23:35:15 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.175.211 Subject: Step 6 From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none In my eyes, the correct way to implement it should be: 1) correct -> gives same result as your standard shell 2) follows good programming practices, and is readable 3) (not particularly important for this project) efficient and scalable Sometimes trial and error is needed to get to the best result From lopasb03@csse.uwa.edu.au Sat Oct 24 02:28:15 2015 Date: Sat Oct 24 02:28:15 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step 7, part 1 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Daniel Mcfall" <21312007@student.uwa.edu.au> wrote: > a < b will execute a with the input of file b (instead of stdin) > > for example, make a text file and type "hello". You can do this by doing: > > echo "hello" > hello.txt > > then type the command tr a-z A-Z < hello.txt > > this will output HELLO (or whatever was in the file, in caps) > > To implement this you will need to redirect the stdin and stdout streams. > > Hope this helps, good luck Thanks Daniel, you're an absolute legend, I don't think I could have asked for a better explanation. Hope you are doing well with the rest of the project. c",) Cheers, Ben. From lopasb03@csse.uwa.edu.au Sat Oct 24 02:31:55 2015 Date: Sat Oct 24 02:31:55 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step 6 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Daniel Mcfall" <21312007@student.uwa.edu.au> wrote: > In my eyes, the correct way to implement it should be: > > 1) correct -> gives same result as your standard shell > 2) follows good programming practices, and is readable > 3) (not particularly important for this project) efficient and scalable > > Sometimes trial and error is needed to get to the best result Thanks Daniel, I will take note of these good points when I go back and test my subshell code, once again thanks for the great input. Cheers, Ben. c",) From lopasb03@csse.uwa.edu.au Sat Oct 24 09:45:45 2015 Date: Sat Oct 24 09:45:45 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step 6 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > "Daniel Mcfall" <21312007@student.uwa.edu.au> wrote: > > > In my eyes, the correct way to implement it should be: > > > > 1) correct -> gives same result as your standard shell > > 2) follows good programming practices, and is readable > > 3) (not particularly important for this project) efficient and scalable > > > > Sometimes trial and error is needed to get to the best result > > Thanks Daniel, I will take note of these good points when I go back and test > my subshell code, once again thanks for the great input. Cheers, Ben. c",) OK, after following Daniels steps this is what I am getting for step 6. The subshells give the same result as standard input, however they don't work in conjunction with the infile/outfile commands. For example, if I was to type (ls & cal) > test.txt ls & cal will print on the screen, but will not print into the test.txt file. Is there something not mentioned in the project specifications that needs to be implemented for this case to work correctly? From fetzee01@csse.uwa.edu.au Sat Oct 24 11:02:01 2015 Date: Sat Oct 24 11:02:01 2015 To: help2002@csse.uwa.edu.au Received: from 122.111.245.242 Subject: Step 6 From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > OK, after following Daniels steps this is what I am getting for step 6. > > The subshells give the same result as standard input, however they don't > work in conjunction with the infile/outfile commands. For example, if I was > to type (ls & cal) > test.txt ls & cal will print on the screen, but will > not print into the test.txt file. Is there something not mentioned in the > project specifications that needs to be implemented for this case to work > correctly? The project specifications do state that this should work for when command is a subshell (step 7 NOTE). I am currently experiencing the same issue as you Ben, and amm also trying to fix it. From graven01@csse.uwa.edu.au Sat Oct 24 12:40:49 2015 Date: Sat Oct 24 12:40:49 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.23.162 Subject: Suppressing programs output From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none Just going over the time command, when mysh runs time ls ...for example it prints out the program TIME output as expected , as well as my on time recording of the execution of the command, to print to stderr as requested, to make it cleaner i only want to print out mysh time, is there anyway to suppress the output of time ? other wise i would have a whole new function just to process time as an individual command where the 2nd argument is the one that is run, and timed. if that makes any sense .. advice appreciated. From mcfald01@csse.uwa.edu.au Sat Oct 24 13:40:27 2015 Date: Sat Oct 24 13:40:27 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.175.211 Subject: Suppressing programs output From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none What do you mean by the program's time output? From graven01@csse.uwa.edu.au Sat Oct 24 14:10:41 2015 Date: Sat Oct 24 14:10:41 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.23.162 Subject: Suppressing programs output From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none so when we run TIME . from the BASH shell . The program "time" will output the execution time of the program given by time ls - produces real 0m0.026s user 0m0.002s sys 0m0.011s this is the output from ./mysh 0.00 real 0.00 user 0.00 sys --THIS IS OUTPUT FROM TIME. Total time = 0.016026 seconds -----THIS IS MY TIME TRACKING. From mcfald01@csse.uwa.edu.au Sat Oct 24 14:39:11 2015 Date: Sat Oct 24 14:39:11 2015 Edit: Sat Oct 24 14:40:59 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.134.4 Subject: Suppressing programs output From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none You shouldnt be getting your bash's time This might be happening if youre calling system() to execute your commands From graven01@csse.uwa.edu.au Sat Oct 24 15:36:15 2015 Date: Sat Oct 24 15:36:15 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.23.162 Subject: Suppressing programs output From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none not using system() calls , just fork, then execv() from the child the time program. From nelsoj07@csse.uwa.edu.au Sat Oct 24 15:40:13 2015 Date: Sat Oct 24 15:40:13 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: Suppressing programs output From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: lightbulb.png X-img: none So for the command: > time [string] [string] You want to get the time, execute the remainder of the command, and then get the time again and check the difference? So could you check if argv[0] is "time" and if so bump the rest of the commands up, then call execute_cmdtree(t) again? From mcfald01@csse.uwa.edu.au Sat Oct 24 16:41:53 2015 Date: Sat Oct 24 16:41:53 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.175.211 Subject: Suppressing programs output From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none ah, possibly running /usr/bin/time then in which case, as Jake said, just increment the pointer when you encounter the time so that it doesn't execute it later on From graven01@csse.uwa.edu.au Sat Oct 24 18:53:31 2015 Date: Sat Oct 24 18:53:31 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.23.162 Subject: Problem running my own commands From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none So I'm tired, and can't see what I'm doing wrong, but without posting my code can you give me suggestions based on the output below as to why "make" works fine but mysh and ./mysh would not? they are both in the same directory. I've been looking for an hour and can't figure it out , probably something tiny but id like to move on. all other commands seem to work as expected, ls, cd, cal etc. it seems allergic to programs that i write. :D mysh.7 mysh mysh Program Not Found PWD is :/Users/Nathan/Documents/Cits2002/A2/ mysh.8 ./mysh ./mysh Program Not Found PWD is :/Users/Nathan/Documents/Cits2002/A2/ mysh.9 make make make: `mysh' is up to date. PWD is :/Users/Nathan/Documents/Cits2002/A2/ From lopasb03@csse.uwa.edu.au Sat Oct 24 19:17:52 2015 Date: Sat Oct 24 19:17:52 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Subshell execution and step 7 (all parts) From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none I have implemented a solution for all parts of step 7, however, my program does not work if I have a subshell as one of the commands. I wonder if anyone else is having this problem, I have spent hours trying to redirect the stdout of my subshell to another file, but as it is I have not even come close. Is there a trick to implementing the subshell's stdout output or the stdin input? Any tips/comments or suggestions that can help me would be greatly appreciated. Thanks. :) From chowda01@csse.uwa.edu.au Sat Oct 24 21:29:01 2015 Date: Sat Oct 24 21:29:01 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.112.22 Subject: Step 8 confusion From: "Anirban Chowdhury" <21432966@student.uwa.edu.au> X-smilie: none X-img: none I am really confused as to how step 8 works. I do get how stdout and stdin works but the confusion lies as to how to decide how many child processes to fork. for eg: command1 | command2 | command3 will require 3 child processes to run at the same time and i will also need to create two different pipes to connect the 3 commands. However the user might type in any number of commands connected through a pipe. Consequently i can't know how many processes or pipes i would require. I hope i could get my point across. Any help would be greatly appreciated. Thanks. From newmal01@csse.uwa.edu.au Sat Oct 24 23:26:56 2015 Date: Sat Oct 24 23:26:56 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: Subshell execution and step 7 (all parts) From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > I have implemented a solution for all parts of step 7, however, my program does not > work if I have a subshell as one of the commands. I wonder if anyone else is having > this problem, I have spent hours trying to redirect the stdout of my subshell to > another file, but as it is I have not even come close. > > Is there a trick to implementing the subshell's stdout output or the stdin input? > Any tips/comments or suggestions that can help me would be greatly appreciated. > > Thanks. :) Hey sorry cant help you for step 7 i was wondering though how could you tell that your Background and subshell executions were working properly From graven01@csse.uwa.edu.au Sun Oct 25 09:00:04 2015 Date: Sun Oct 25 09:00:04 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.23.162 Subject: Off Topic From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none Anyone else feel like watching inception after getting stuck into this project? From 00014979@csse.uwa.edu.au Sun Oct 25 09:00:55 2015 Date: Sun Oct 25 09:00:55 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Q3 part 2 From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > consider I'm in /User/Documents > in ./mysh i type > cd /User/Documents/MYFOLDER > it will change > However if i was in the same directory and just type in > cd MYFOLDER > it won't change, But it *will* change directory to MYFOLDER if you have the current directory '.' as an entry in your CDPATH variable. From 00014979@csse.uwa.edu.au Sun Oct 25 09:18:40 2015 Date: Sun Oct 25 09:18:40 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Step 6 From: "Christopher McDonald" X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > The subshells give the same result as standard input, however they don't > work in conjunction with the infile/outfile commands. For example, if I was > to type (ls & cal) > test.txt ls & cal will print on the screen, but will > not print into the test.txt file. Is there something not mentioned in the > project specifications that needs to be implemented for this case to work > correctly? If you play with the webpage to view different commands, you'll notice that simple commands and subshells are the only types of CMDTREE that can have I/O redirection to and from files. So, if you've correctly implemented the code to perform file redirection for simple commands, then the same code should work for subshells, too. And if you're using the same sequence of statements twice, then they best belong in a new function. Is your file redirection correctly working for simple commands? Are you using the system call dup() or dup2() ? From 00014979@csse.uwa.edu.au Sun Oct 25 09:21:14 2015 Date: Sun Oct 25 09:21:14 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Problem running my own commands From: "Christopher McDonald" X-smilie: none X-img: none "Nathan Graves" <21256779@student.uwa.edu.au> wrote: > all other commands seem to work as expected, ls, cd, cal etc. it seems allergic to programs > that i write. :D Are your own programs in a directory that is searched using the contents of the PATH variable? If your programs are in the current directory, do you have '.' as a member of PATH ? From 00014979@csse.uwa.edu.au Sun Oct 25 09:25:26 2015 Date: Sun Oct 25 09:25:26 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.118.168 Subject: Off Topic From: "Christopher McDonald" X-smilie: movie.png X-img: none Reading the questions on this forum - Groundhog Day. From graven01@csse.uwa.edu.au Sun Oct 25 10:22:45 2015 Date: Sun Oct 25 10:22:45 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.23.162 Subject: Problem running my own commands From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none yeah that was it, i looked this morning it seemed obvious. thank for the response. From graven01@csse.uwa.edu.au Sun Oct 25 13:00:44 2015 Date: Sun Oct 25 13:00:44 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Forking Hell. From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none I forking all over the place.. how would the user determine if they are in a subshell or the original? is it possible to give an identity number in front of the prompt i.e. mysh.5 could be 1.mysh.5, 2.mysh.5 etc. From liaoj02@csse.uwa.edu.au Sun Oct 25 13:19:30 2015 Date: Sun Oct 25 13:19:30 2015 To: help2002@csse.uwa.edu.au Received: from 43.252.114.58 Subject: step 4 , where to go? From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Hello, I am having trouble figuring out where to code for step4. I did basic external command and internal command in execute.c under the default function. How (or where) do I access the information that record whether mine input commands have those special symbols? Is it (t->NODETYPE)?Moreover, are those types defined as a boolean value or a symbols in strc NODETYPE? Thanks From abusha02@csse.uwa.edu.au Sun Oct 25 14:01:40 2015 Date: Sun Oct 25 14:01:40 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.66.133 Subject: step 4 , where to go? From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > Hello, I am having trouble figuring out where to code for step4. I did basic external > command and internal command in execute.c under the default function. > > How (or where) do I access the information that record whether mine input commands have > those special symbols? Is it (t->NODETYPE)?Moreover, are those types defined as a boolean > value or a symbols in strc NODETYPE? > > Thanks Those types are recorded as t->type, so you'd want to add more cases to the switch statement. One case for t->type == N_AND, one for t->type == N_OR, and one for t->type == N_SEMICOLON. You'd want to do this in the execute_cmdtree() function. Don't forget to break at the end of every case in a switch statement. Once you've added these cases, just think about what each case entails. I'd highly recommend using recursion for these three cases. From abusha02@csse.uwa.edu.au Sun Oct 25 14:17:03 2015 Date: Sun Oct 25 14:17:03 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.66.133 Subject: Forking Hell. From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none As I understood it, the subshell was supposed to terminate itself right after executing the commands given to it. i.e, the command sequence (cal && ls) would fork, execute cal && ls inside the child (subshell) process, and then terminate the terminate the child (subshell) process once it was done. I got this impression because the page said "the exit value of a subshell is the exit value of the command sequence executed by the subshell," so I didn't think you could then keep the subshell running and continue to execute commands with it. Perhaps someone can correct me if I am wrong here. Regarding how to keep track of what subshell you're in, you could have two global variables int nsubshells, this_shell; Whenever you're about to fork() a new subshell, increment nsubshells to indicate you've now got one more subshell running than you had before. Right after the fork, as soon as you determine you're in the child with the pid==0 check, you should write this_shell = nsubshells This makes the subshells own copy of this_shell act as a determinant for which subshell it is. And whenever you terminate a subshell, you could decrement nsubshells right after, indicating you have one less subshell running. Now, within each subshell, you can at some point print this_shell to show the user which subshell they're in. A few notes on the above. I haven't tested it, and don't know how it'll work in the end, so it's not a guaranteed solution, and could fail miserably for all I know. Secondly, if I'm understanding the task right, I don't think this is necessary at all, given what I said earlier about exiting the subshell as soon as its executed its commands. Thirdly, I believe there's a much simpler way for a user to determine if they're in a subshell: (exit) will open a new subshell and exit it. This should, in effect, do absolutely nothing for the user (mac OSX terminal does exactly this: nothing). If you are in a subshell, calling exit should not terminate your entire mysh program. Thus if you call exit and it doesn't seem to do anything, you've probably just exited a subshell. This is also a decent way to determine if you are forking correctly for your subshells. If (exit) terminates your entire program, you probably aren't. From graven01@csse.uwa.edu.au Sun Oct 25 14:17:12 2015 Date: Sun Oct 25 14:17:12 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.23.162 Subject: Testing. From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none Chris, i believe m close to being finished , will there be any testing program that might help us find bugs /test cases etc From abusha02@csse.uwa.edu.au Sun Oct 25 14:27:13 2015 Date: Sun Oct 25 14:27:13 2015 To: help2002@csse.uwa.edu.au Received: from 124.148.66.133 Subject: Forking Hell. From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none Just to add to the above, regarding my assumption that we exit the subshell right after executing its commands, I've run the following in Mac OSC terminal: (exit) //Seems to do nothing, so it probably creates a new subshell and exits it From this, we can see that exiting a subshell obviously leaves the parent shell completely intact exit //Closes the shell process. Run in the parent, this terminates the entire shell From this, we can assume that if a subshell continued to run after executing its commands, you might have something like: mysh1(parent) : (cal && ls) mysh2(subshell) : pwd //RUN IN SUBSHELL mysh2(subshell) : ls //RUN IN SUBSHELL mysh2(subshell) : exit //EXIT SUBSHELL mysh1(parent again): ..... I think this is what you were confused about. You'd be thinking, you could run (cal) from within the subshell, and then get a second subshell, and continue to work your way down into subshell abyss, and thus you wanted to be able to report to the user what subshell they're in. The only thing is, in Mac OSX, running: mysh1(parent): (cal) mysh?(which one?): exit Terminates the entire shell. Thus, the 'exit' statement there must have been run from the parent shell, which means that the command (cal) must have terminated the subshell right after executing 'cal'. This is what I was talking about in the first post, with regards to exiting a subshell after executing its commands. This is how I thought about it, anyway. From graven01@csse.uwa.edu.au Sun Oct 25 14:34:56 2015 Date: Sun Oct 25 14:34:56 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.23.162 Subject: Forking Hell. From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none thanks mate, i really appreciate the detailed response, gave me some good insight From marleh01@csse.uwa.edu.au Sun Oct 25 15:55:17 2015 Date: Sun Oct 25 15:55:17 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.141.78 Subject: Step 1 confusion From: "Harrison Marley" <21522889@student.uwa.edu.au> X-smilie: none X-img: none I tried this, but keep getting the below printout when running the command "/bin/ls": "usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]" Should it not just work as it usually does in bash? other commands like "cal" seem to not print anything out at all. my execv looks like: execv(t->argv[0], NULL); From graven01@csse.uwa.edu.au Sun Oct 25 16:32:15 2015 Date: Sun Oct 25 16:32:15 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.23.162 Subject: something's wrong From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none [forkpty: Resource temporarily unavailable] [Could not create a new process and open a pseudo-tty.] can't open a new bash and have about 700 ./mysh running don't want to kill each process individually and can't mass kill without terminal, is there any way to murder all these processes using activity monitor :D i think one of my forks is going crazy. From liaoj02@csse.uwa.edu.au Sun Oct 25 16:42:02 2015 Date: Sun Oct 25 16:42:02 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.125.126 Subject: step 4 , where to go? From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none THanks. SHould I put the first three out of the cmd_exeuction()and just call it once the command line condition is matched? From nelsoj07@csse.uwa.edu.au Sun Oct 25 16:50:32 2015 Date: Sun Oct 25 16:50:32 2015 To: help2002@csse.uwa.edu.au Received: from 60.228.251.110 Subject: something's wrong From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none You just fork bombed yourself :) I've done it a bunch accidentally testing this project if I'm completely honest, shutting down manually is the only way I could kill them all easily. Lesson learnt I guess! My guess is you're fork is recursively calling itself and not exiting, quite problematic! From graven01@csse.uwa.edu.au Sun Oct 25 16:55:06 2015 Date: Sun Oct 25 16:55:06 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.23.162 Subject: something's wrong From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > You just fork bombed yourself :) > > I've done it a bunch accidentally testing this project if I'm completely honest, shutting down > manually is the only way I could kill them all easily. Lesson learnt I guess! > > My guess is you're fork is recursively calling itself and not exiting, quite problematic! Yeah had to restart. think there is a problem with the sub shell or background fork. better fix it before i test it again :D From nelsoj07@csse.uwa.edu.au Sun Oct 25 16:55:08 2015 Date: Sun Oct 25 16:55:08 2015 To: help2002@csse.uwa.edu.au Received: from 60.228.251.110 Subject: Step 1 confusion From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none From the man page: int execv(const char *path, char *const argv[]); Link here: http://linux.die.net/man/3/execv argv[] needs to at minimum contain {/bin/ls, NULL}. So Li's full call to execv is execv( /bin/ls, {/bin/ls, NULL} ); In general, the program name always needs to be included in argv as the first argument, even if not supplying any options to the program. Does that make sense at all, I'm not really a hundred percent sure of my wording? :) From liaoj02@csse.uwa.edu.au Sun Oct 25 17:04:08 2015 Date: Sun Oct 25 17:04:08 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.125.126 Subject: step 4 , where to go? From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Also, recursion should be used for what tasks? Like we dont know how many cmd arguments are there so we do it recursivly? From mcfald01@csse.uwa.edu.au Sun Oct 25 17:55:39 2015 Date: Sun Oct 25 17:55:39 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.190.42 Subject: step 4 , where to go? From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none I used recursion to traverse the CMDTREE, I didn't do much with the arguments besides pass the pointer to execv, the parser does all the hard work there. From lopasb03@csse.uwa.edu.au Sun Oct 25 20:16:12 2015 Date: Sun Oct 25 20:16:12 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step 8 confusion From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > I am really confused as to how step 8 works. I do get how stdout and stdin works but the > confusion lies as to how to decide how many child processes to fork. > > for eg: command1 | command2 | command3 > > will require 3 child processes to run at the same time and i will also need to create two > different pipes to connect the 3 commands. However the user might type in any number of > commands connected through a pipe. Consequently i can't know how many processes or pipes i > would require. > > I hope i could get my point across. > Any help would be greatly appreciated. > > Thanks. I am also having problem with step 8, does anyone know how we are supposed to approach the coding for this step, and also does our code need to be able to handle an unlimited amount of pipes in one command line, or is there a maximum number our command line must handle? Any help/comments/suggestions at this point would be appreciated. Cheers, Ben. c",) From ahmedm07@csse.uwa.edu.au Sun Oct 25 21:04:43 2015 Date: Sun Oct 25 21:04:43 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.56.82 Subject: Exit Problem From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none Hey. I am not sure what i am doing wrong. Frankly quite perplexed. Why is it that i have to press ^C twice to exit out of mysh. Has anyone encountered this same issue? Thanks, MA From lis63@csse.uwa.edu.au Sun Oct 25 21:41:36 2015 Date: Sun Oct 25 21:41:36 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.221.171 Subject: confusion on step 5 From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none Hi, I'm not sure what "The exit value of background execution is success unless the fork call fails" means. I think there are 2 fork calls, however here is only one mentioned. For example, if input is " ls & cal ", I think mysh will create 2 child processes at almost the same time. So there are 2 fork calls, fork() 1 for ls and fork() 2 for cal, and there are 4 results: both fork calls succeed fork() 1 succeeds and fork() 2 not fork() 2 succeeds and fork() 1 not both are unsuccessful. What's the exit value in the second and third results? Besides, what if the child process fails when running? From ahmedm07@csse.uwa.edu.au Sun Oct 25 21:58:41 2015 Date: Sun Oct 25 21:58:41 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.56.82 Subject: PWD directory included in PATH From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none Should the PWD be included in PATH? Is that something that is part of the project? If so then wouldn't that make the Shell or technically the computer and user be vulnerable to an attack? From weinej01@csse.uwa.edu.au Sun Oct 25 22:04:00 2015 Date: Sun Oct 25 22:04:00 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.102.253 Subject: timing command From: "Jake Weiner" <20749646@student.uwa.edu.au> X-smilie: none X-img: none I am just a bit confused with this command. What does it mean that we "should time the execution of "remainder" of the command"? Does it just mean how long it will take to run a command such as ls? Would we then do this by measuring the time when the ls command is called (within the child) and then the time when it finishes (within the parent) and subtracting one from the other? From lopasb03@csse.uwa.edu.au Mon Oct 26 07:03:03 2015 Date: Mon Oct 26 07:03:03 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step 8 confusion From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > ANONYMOUS wrote: > > > I am really confused as to how step 8 works. I do get how stdout and stdin works but the > > confusion lies as to how to decide how many child processes to fork. > > > > for eg: command1 | command2 | command3 > > > > will require 3 child processes to run at the same time and i will also need to create two > > different pipes to connect the 3 commands. However the user might type in any number of > > commands connected through a pipe. Consequently i can't know how many processes or pipes i > > would require. > > > > I hope i could get my point across. > > Any help would be greatly appreciated. > > > > Thanks. > > I am also having problem with step 8, does anyone know how we are supposed to approach the > coding for this step, and also does our code need to be able to handle an unlimited amount of > pipes in one command line, or is there a maximum number our command line must handle? > > Any help/comments/suggestions at this point would be appreciated. > > Cheers, Ben. c",) I need some clarifications on this step urgently, as I think I am wasting my time trying to write a pipeline code that can calculate any number of pipelines in sequence. I have managed to write the correct code for command | command | command , but stopped there because it was getting too complicated to keep on adding more pipes and commands. I tried to do it using conditions and loops but that way seemed even more difficult to implement Does anyone else have any thoughts on this step, or knows a way to dynamically account for an unlimited number of pipes and commands, any help would be appreciated. Thanks, Ben. :) From graven01@csse.uwa.edu.au Mon Oct 26 07:03:09 2015 Date: Mon Oct 26 07:03:09 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Exit Problem From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none "Maktoom Ahmed" <21728592@student.uwa.edu.au> wrote: > Hey. > > I am not sure what i am doing wrong. Frankly quite perplexed. Why is it that i have > to press ^C twice to exit out of mysh. Has anyone encountered this same issue? > > Thanks, > MA Most likely one of your forks isn't exiting properly? From nelsoj07@csse.uwa.edu.au Mon Oct 26 08:34:19 2015 Date: Mon Oct 26 08:34:19 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: Step 8 confusion From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Can you achieve it with recursion? Each time that you get to a pipe, you could re call execute command tree for the left and right nodes, if they are a command or other type of node then they will do that, if the right is again a pipe node it will work the same (in theory). Type in echo ls | bash | sort into the online cmdtree display Chris has provided to see what I mean. In pseudo code: run_pipe(t) { // do pipey stuff execute_cmdtree(t->left); execute_cmdtree(t->right); } execute_cmdtree(t) { switch (t->node_type) { case n_pipe: run_pipe; break; case n_command: //do command break; // other switch statements } } Does that make sense at all? Unsure of the best way to explain what I mean :) From nelsoj07@csse.uwa.edu.au Mon Oct 26 08:36:23 2015 Date: Mon Oct 26 08:36:23 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: timing command From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none That's it :) I use this bad boy to waste time when I call time so that I can see a little more substantial a result: #include #include // Compile this program with: // cc -std=c99 -Wall -Werror -pedantic -o rot rot.c int main(int argc, char *argv[]) { printf("WASTING TIME...\n"); for ( int i = 0; i < 1000000000; i++) {} return 0; } From liaoj02@csse.uwa.edu.au Mon Oct 26 08:48:42 2015 Date: Mon Oct 26 08:48:42 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.125.247 Subject: step 4 , where to go? From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Is my logic right here: Semicoln has the highest priority; If ; is presented , then the seperate then command line into two part,and identify what the next type is. Base case is N_COmmand, where we should execs(t->argue[0],argv) If no ; is presented, do it from left to right order. However should we write code to tell the tree to point to left and right or the parser already did for us? From liaoj02@csse.uwa.edu.au Mon Oct 26 08:52:45 2015 Date: Mon Oct 26 08:52:45 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.125.247 Subject: Step 8 confusion From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Hi Jake. For step4 Is my logic right here:? Semicoln has the highest priority; If ; is presented , then the seperate then command line into two part,and identify what the next type is. Base case is N_COmmand, where we should execs(t->argue[0],argv) If no ; is presented, do it from left to right order. so as you say before, execute_cmdtree(t->left || right) means split the tree. Thanks From 00014979@csse.uwa.edu.au Mon Oct 26 09:27:24 2015 Date: Mon Oct 26 09:27:24 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: confusion on step 5 From: "Christopher McDonald" X-smilie: none X-img: none "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > Hi, I'm not sure what "The exit value of background execution is success unless the > fork call fails" means. I think there are 2 fork calls, however here is only one > mentioned. Why do you believe that there are two calls to fork? If you request ls & then only 1 fork is required, the new child will run ls, and the original parent will not wait for it to finish. From 00014979@csse.uwa.edu.au Mon Oct 26 09:33:14 2015 Date: Mon Oct 26 09:33:14 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: PWD directory included in PATH From: "Christopher McDonald" X-smilie: none X-img: none "Maktoom Ahmed" <21728592@student.uwa.edu.au> wrote: > Should the PWD be included in PATH? Is that something that is part of the project? If > so then wouldn't that make the Shell or technically the computer and user be > vulnerable to an attack? Whether the current working directory, named ".", is in PATH or not, does not affect the normal execution of the project - just as it doesn't affect the execution of the standard shells; it just makes you type a bit more: ./mycal As to it making a user account vulnerable to an attack, a little, if you're careless: http://www.faqs.org/faqs/unix-faq/faq/part2/section-13.html From 00014979@csse.uwa.edu.au Mon Oct 26 09:34:49 2015 Date: Mon Oct 26 09:34:49 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: timing command From: "Christopher McDonald" X-smilie: none X-img: none Also discussed here: https://secure.csse.uwa.edu.au/run/help2002?p=np&a=824&all=y2 From led05@csse.uwa.edu.au Mon Oct 26 09:36:49 2015 Date: Mon Oct 26 09:36:49 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.69.149 Subject: confusion on step 5 From: "Henry Le" <21317911@student.uwa.edu.au> X-smilie: none X-img: none Just for clarification, if the process in the child fails, would the N_BACKGROUND node fail? Or just return the parent process exit status if it succeeds(i.e the failure only happens in the event of failing to call fork() )? From 00014979@csse.uwa.edu.au Mon Oct 26 09:37:49 2015 Date: Mon Oct 26 09:37:49 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: step 4 , where to go? From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > How (or where) do I access the information that record whether mine input commands have > those special symbols? Is it (t->NODETYPE)?Moreover, are those types defined as a boolean > value or a symbols in strc NODETYPE? It seriously sounds like you have not used the webpage to display the parsed CMDTREE structure: https://secure.csse.uwa.edu.au/run/help2002?p=np&a=824&all=y2 From 00014979@csse.uwa.edu.au Mon Oct 26 09:47:13 2015 Date: Mon Oct 26 09:47:13 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Step 8 confusion From: "Christopher McDonald" X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > I need some clarifications on this step urgently, as I think I am wasting my time trying to write > a pipeline code that can calculate any number of pipelines in sequence. I have managed to write > the correct code for command | command | command , but stopped there because it was getting too > complicated to keep on adding more pipes and commands. I tried to do it using conditions and > loops but that way seemed even more difficult to implement It's unclear what you mean, or are trying to do, when you describe counting or calculating the number of pipes required. Into the web program, enter the command: a | b | c | d | e | f | g Report back here that you can see the pattern, and that Jake's suggestion is clear to you. From 00014979@csse.uwa.edu.au Mon Oct 26 09:49:19 2015 Date: Mon Oct 26 09:49:19 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: confusion on step 5 From: "Christopher McDonald" X-smilie: none X-img: none "Henry Le" <21317911@student.uwa.edu.au> wrote: > Just for clarification, if the process in the child fails, would the N_BACKGROUND node fail? Or just Who knows? Who cares? If no other process is waiting for it to finish, does it matter if it succeeds or fails? Hmmmm, reminds me of a story about trees falling in a forest. From lopasb03@csse.uwa.edu.au Mon Oct 26 11:34:13 2015 Date: Mon Oct 26 11:34:13 2015 Edit: Mon Oct 26 11:35:50 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step 8 confusion From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > > > I need some clarifications on this step urgently, as I think I am wasting my time trying to write > > a pipeline code that can calculate any number of pipelines in sequence. I have managed to write > > the correct code for command | command | command , but stopped there because it was getting too > > complicated to keep on adding more pipes and commands. I tried to do it using conditions and > > loops but that way seemed even more difficult to implement > > It's unclear what you mean, or are trying to do, when you describe counting or calculating the number of > pipes required. > > Into the web program, enter the command: a | b | c | d | e | f | g > > Report back here that you can see the pattern, and that Jake's suggestion is clear to you. I have entered the command a | b | c | d | e | f | g several times into the web program, along with several other types of command sequences, so I understand what is happening in that respect. I am also doing exactly what jake has suggested, with calling an external function from within a switch loop for the case when t->type == N_PIPE. Neither of these things are the problem for me. From Jakes perspective: run_pipe(t) { // do pipey stuff execute_cmdtree(t->left); execute_cmdtree(t->right); } execute_cmdtree(t) { switch (t->node_type) { case n_pipe: run_pipe; break; case n_command: //do command break; // other switch statements } } This is exactly the approach that I have taken, however my "do pipey stuff" is the problem. My run-pipe(t) code increases exponentially everytime I add the ability of an extra pipe to be used in sequence. For example, with 3 commands and two pipes, my code creates 3 fork()'s, then I must close the input/outputs of the stdin and stdout from that pipeline that I am not using. Everytime I add another pipe and command to the end of my cmdline I must account for it, and it means writing another 10 line block of code (at least). I am having trouble creating a loop to deal with the amount of pipes/commands in my run_pipe(t) function. I anybody knows how to create a run_pipe(t) function that can deal with an unlimited amount of pipes and commands in sequence could you please post in this forum. I would go to a tute today, but as it is Monday and it was just the weekend, I have not had the opportunity in the last 4 days to get any external help. My group partner is also lost on how to achieve this... Thanks for your time, Ben. c",) From nelsoj07@csse.uwa.edu.au Mon Oct 26 11:46:23 2015 Date: Mon Oct 26 11:46:23 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: Step 8 confusion From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none If you have a command in the form: a | b | c Then you have two pipe nodes total. Your first pipe node (or topmost in the tree, not sure of phrasing) has a left and right pointer to other cmd_tree nodes. On the left is a command node and on the right another pipe command. My pseudo code version of execute_cmdtree will run on the top most node and recognising that it's a pipe, call the function run_pipe. This will "do pipey stuff" and then call execute_cmdtree again for the left and right nodes. For the left node this will recognise that it is a command node and do the command "a" . For the right node, it will recognise that it is a pipe_node and again call execute_cmdtree again for the left and right nodes. For the left node this will recognise that it is a command node and do the command "b" and then the right node will do the command "c". Does that make sense? Obviously the "do pipey stuff" needs to work, but then it should just be a call or function that can be used again if or when needed. The same form would work no matter how many pipes are needed, with the same amount of code. Go to this url: https://secure.csse.uwa.edu.au/run/cmdtree and try the sequence a | b | c to see visually what I mean in terms of the node relationships. From graven01@csse.uwa.edu.au Mon Oct 26 12:10:13 2015 Date: Mon Oct 26 12:10:13 2015 Edit: Mon Oct 26 12:23:16 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: PLEASE HELP I NEED TO KILL SOME CHILDREN!! From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none Sorry for the poor taste title :D ok so when i fork my subshell it doesn't call an exec function there buy not replacing the memory space and actually running something but i want him dead... case 0 // CHILD myfunction(); //IM NOT DEAD HERE break; //NOW IM LOOSE IN THE REAL WORLD (ZOMBIE) ? default : // IM THE PARENT AND I WANT TO MURDER MY ZOMBIE CHILD ..... Maybe i'm going about this all wrong. Pointers ? ive tried kill(pid ,SIGKILL); but compiler tells me implicit definition of kill in c99 , checked man cant see any includes From lopasb03@csse.uwa.edu.au Mon Oct 26 12:11:53 2015 Date: Mon Oct 26 12:11:53 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step 8 confusion From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Thanks for the tips Jake, I will give it another go. Cheers, Ben. c",) From lis63@csse.uwa.edu.au Mon Oct 26 12:59:22 2015 Date: Mon Oct 26 12:59:22 2015 To: help2002@csse.uwa.edu.au Received: from 180.216.42.56 Subject: confusion on step 5 From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > > > Hi, I'm not sure what "The exit value of background execution is success unless the > > fork call fails" means. I think there are 2 fork calls, however here is only one > > mentioned. > > Why do you believe that there are two calls to fork? > > If you request ls & > then only 1 fork is required, the new child will run ls, and the original parent will not wait > for it to finish. Thank you. But as far as I'm concerned, if the parent process runs cal, the execve() function will replace the parent process with a new process image, as a result mysh will exit after cal finished. So I think the parent process needs to create a child process and run cal in the child process. From nelsoj07@csse.uwa.edu.au Mon Oct 26 12:59:28 2015 Date: Mon Oct 26 12:59:28 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: Step 8 confusion From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none No problem, hope that helped! From mcfald01@csse.uwa.edu.au Mon Oct 26 13:07:10 2015 Date: Mon Oct 26 13:07:10 2015 Edit: Mon Oct 26 13:08:33 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.165.231 Subject: PLEASE HELP I NEED TO KILL SOME CHILDREN!! From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none Make sure that your child is guaranteed to either exit or successfully run a program that means make your function return or exit, and having something like exitstatus = my_function(); exit(exitstatus); or execv(); //doesn't return if successful exit(EXIT_FAILURE); Edit: That will kill your child process, but it will still be a zombie until the parent uses wait() to free up the resources, or at least I think it works something like that. From lopasb03@csse.uwa.edu.au Mon Oct 26 17:02:07 2015 Date: Mon Oct 26 17:02:07 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step 8 confusion From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > No problem, hope that helped! OK, I think I have step 8 done and dusted, however I am not 100% sure. Does anybody know of any example command lines using pipelines that will verify that my code is up to standard? From graven01@csse.uwa.edu.au Mon Oct 26 18:40:43 2015 Date: Mon Oct 26 18:40:43 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: o.t From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none Anyone seen that comic that goes something like. "My code wont work. i've been trying for hours and i have no idea why!!!" "Oh wait my code works....I still have no idea why!!!" i kinda feel like i'm throwing shit at a wall until something sticks. maybe i need a better learning approach. anyone else feel like this or y'all know what your actually doing :D ? From ahmedm07@csse.uwa.edu.au Mon Oct 26 18:49:35 2015 Date: Mon Oct 26 18:49:35 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.56.82 Subject: ERROR REPORTING DURING STEP 2 From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none Hey, So basically i have a function for step 2 where what happens is that i parse the PATH and attach /"my command from argv" to it and then execute accordingly. Now this is all done in a loop so it cycles through all of the directory possibilties and therefore find the program under at least one. So my output is something like this for ls: mysh.2 ls -a ERROR DURING EXECUTION: No such file or directory ERROR DURING EXECUTION: No such file or directory ERROR DURING EXECUTION: No such file or directory ERROR DURING EXECUTION: No such file or directory ERROR DURING EXECUTION: No such file or directory . Makefile execute.o globals.o mysh.c mysh.o parser.c .. execute.c globals.c mysh mysh.h mysh.zip parser.o ERROR DURING EXECUTION: No such file or directory ERROR DURING EXECUTION: No such file or directory Whereas it reports a error for everytime it is unable to execute ls which is basically under every directory except one. How do i stop this or report errors only once? I am unable to figure this out. Let me know. Thanks From graven01@csse.uwa.edu.au Mon Oct 26 18:56:53 2015 Date: Mon Oct 26 18:56:53 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: ERROR REPORTING DURING STEP 2 From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none i just have a printf(stderr, "Cannotfind" ); after my loop that looks for the program if it gets there it hasn't found it and returns that status. From mcfald01@csse.uwa.edu.au Mon Oct 26 18:57:06 2015 Date: Mon Oct 26 18:57:06 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.165.231 Subject: ERROR REPORTING DURING STEP 2 From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none You are making a call to perror (I assume) whenever one segment of path is checked. Instead consider checking/calling perror only if none of them are successful, not after each one also consider stopping the search after it successfully finds (and executes or reads from in the case of a script) a file From 00014979@csse.uwa.edu.au Mon Oct 26 19:30:43 2015 Date: Mon Oct 26 19:30:43 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: Step 8 confusion From: "Christopher McDonald" X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > OK, I think I have step 8 done and dusted, however I am not 100% sure. Does > anybody know of any example command lines using pipelines that will verify that my > code is up to standard? Producing the same output as the standard shells is probably 'verification' enough, providing that all of your process in the pipeline terminate, and none live on and attempt to keep reading from the keyboard, etc. This 2 process pipeline will count things in a file: cat mysh.h | wc This 3 process pipeline should produce the same output: cat mysh.h | wc | cat and the 4 process pipeline should just produce the number '1': cat mysh.h | wc | cat | wc -l If you wrote the reverse program from Labsheet 6, you could try: reverse mysh.h | reverse | reverse | reverse | .... From 00014979@csse.uwa.edu.au Mon Oct 26 19:37:37 2015 Date: Mon Oct 26 19:37:37 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: ERROR REPORTING DURING STEP 2 From: "Christopher McDonald" X-smilie: none X-img: none "Maktoom Ahmed" <21728592@student.uwa.edu.au> wrote: > Whereas it reports a error for everytime it is unable to execute ls which is > basically under every directory except one. > > How do i stop this or report errors only once? I am unable to figure this out. Let me > know. Thanks It really seems that you're iterating through your PATH's values in a parent process. ?? How would your program's operation change if you iterated in the child? From ahmedm07@csse.uwa.edu.au Mon Oct 26 20:03:48 2015 Date: Mon Oct 26 20:03:48 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.56.82 Subject: ERROR REPORTING DURING STEP 2 From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none Thanks, Not sure what will happen but i'll give it a try. :) From graven01@csse.uwa.edu.au Mon Oct 26 20:11:34 2015 Date: Mon Oct 26 20:11:34 2015 Edit: Mon Oct 26 20:28:15 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: open() help From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none im trying to use open to get a fd for use in dup2, man comes up short websites seem conflicting, any pointers would be appreciated! nevermind found it. however new question, how are you guys handling ">>" case if infile != null // Process (redirect stdin to file) if outfile != null // process (redirect stdout to file) do i need to manually search the string and find ">>" and correlate it where it is int the sequence of possibly long testing commands? From ahmedm07@csse.uwa.edu.au Mon Oct 26 20:25:42 2015 Date: Mon Oct 26 20:25:42 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.56.82 Subject: ERROR REPORTING DURING STEP 2 From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none I am not sure whats happening, however i am incrementing a variable in my child process but when i use a if statement with that variable as a conditional statement. It uses the value that it was intialized to. Why is this? I have suspicion but not sure right now. From chinnd01@csse.uwa.edu.au Mon Oct 26 21:11:56 2015 Date: Mon Oct 26 21:11:56 2015 To: help2002@csse.uwa.edu.au Received: from 110.141.157.113 Subject: A distraction From: "David Chinnery" <21142701@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > Great test of the new shell functionality, highly approve. I feel the source is strong in you young padawan. Try this you will cmatrix Not sure how to install it on fruity computers but on debian based stuff use $ sudo apt-get install cmatrix Oh an other to test your mysh with yes hello ctrl + C to get out From lis63@csse.uwa.edu.au Mon Oct 26 21:34:55 2015 Date: Mon Oct 26 21:34:55 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.185.96 Subject: confusion on step 5 From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none whoops, I get it now. Thank you. From lopasb03@csse.uwa.edu.au Tue Oct 27 00:21:15 2015 Date: Tue Oct 27 00:21:15 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step 8 confusion From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > > > OK, I think I have step 8 done and dusted, however I am not 100% sure. Does > > anybody know of any example command lines using pipelines that will verify that my > > code is up to standard? > > Producing the same output as the standard shells is probably 'verification' enough, providing > that all of your process in the pipeline terminate, and none live on and attempt to keep > reading from the keyboard, etc. > > This 2 process pipeline will count things in a file: > > cat mysh.h | wc > > This 3 process pipeline should produce the same output: > > cat mysh.h | wc | cat > > and the 4 process pipeline should just produce the number '1': > > cat mysh.h | wc | cat | wc -l > > If you wrote the reverse program from Labsheet 6, you could try: > > reverse mysh.h | reverse | reverse | reverse | .... > Thanks Chris and Jake, I ended up getting my piper function working 100%, I couldn't have done it without your help. Many Thanks, Ben. c",) From thompj20@csse.uwa.edu.au Tue Oct 27 00:34:07 2015 Date: Tue Oct 27 00:34:07 2015 Edit: Tue Oct 27 00:35:58 2015 To: help2002@csse.uwa.edu.au Received: from 60.224.118.25 Subject: Step 5 error From: "Joseph Thompson" <21517108@student.uwa.edu.au> X-smilie: none X-img: none For step 5 we're finding that when forking the process, to allow background execution, the program behaves unusually for subsequent output. For instance, running: ls & pwd will print both the standard output of ls and pwd as expected, however you then have to press enter to get the normal terminal prompt, and in addition, there is a prompt between the two outputs. I don't know if this is incorrect. In addition, whenever another process that gives output is called, after previously running a backround command in the mysh terminal, an extra terminal prompt with the number already incremented prints before the output. Here's an example ... mysh.4 ls mysh.5 a.out globals.c life.c mysh.o v15 26-10-15.zip execute.c globals.o Makefile parser.c execute.o hellotest mysh parser.o execute_type.c hello.txt mysh.c path_variable.c execute_type.o life mysh.h path_variable.o As you can see, the prompt is coming before all the output, and then no prompt is coming after the output. Our implementation essentially has the main process forking, then the two branches are dealt with by the program, without the right branch waiting for the left branch. So essentially, the left branch is executed as normal, and then immediately after it has finished the child process exits. We believe the child shouldn't be affecting the parent as all variables are duplicated in fork. However, as file descriptors (that might not be the technical term) aren't duplicated we think the error is something to do with them. Any suggestions on how to deal with this issue are much appreciated. From abusha02@csse.uwa.edu.au Tue Oct 27 01:39:50 2015 Date: Tue Oct 27 01:39:50 2015 To: help2002@csse.uwa.edu.au Received: from 114.30.118.120 Subject: Step 5 error From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: b034a82f04cc04127d7b24b2282f2b5e.png Just to confirm, did you mean "ls &" instead of "ls" for the mysh.4 prompt? If so, then your terminals behavior is, as I understand it, expected. This is because when you run something in the background, the next prompt should show up immediately, and allow you to continue to run other commands while the first process runs in the background. This being the case, since the "ls &" command finishes so fast that you don't really get the chance to type anything before the output prints, it ends up printing after the prompt. What's happening is something like this: 1. The ls command is called, but the parent is told not to wait for it (it's a background process) 2. The parent, not having waited for ls to finish, prints the next input prompt 3. ls finishes, and prints its output, long before the user even notices the prompt 4. The program continues to wait for user input Thus, (and I'm assuming here that you DID mean "ls &" instead of "ls" for the mysh.4 prompt) what you are experiencing is quite normal, and even expected. To prove it, that's what the main terminal does as well. I've attached an image proving this. I called the command "pwd &" from bash, and it does exactly what your mysh (and my own) do: it prints the next prompt, then pwd prints its result before I have a chance to input my next command sequence. Thus, when I enter the next command, an echo command, there is no prompt before it, as the prompt was printed almost immediately before pwd finished. From 00014979@csse.uwa.edu.au Tue Oct 27 04:49:01 2015 Date: Tue Oct 27 04:49:01 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: open() help From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > how are you guys handling ">>" case > > do i need to manually search the string and find ">>" and correlate it where it is int the > sequence of possibly long testing commands? Run the web-based program, and compare a command with > with one with >> From 00014979@csse.uwa.edu.au Tue Oct 27 04:51:38 2015 Date: Tue Oct 27 04:51:38 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: ERROR REPORTING DURING STEP 2 From: "Christopher McDonald" X-smilie: none X-img: none "Maktoom Ahmed" <21728592@student.uwa.edu.au> wrote: > I am not sure whats happening, however i am incrementing a variable in my child > process but when i use a if statement with that variable as a conditional statement. > It uses the value that it was intialized to. (if I'm understanding your description, correctly) If you modify a variable in a child process, the parent cannot/will not see that modified value. The variables of a child process and its parent process, like all processes, are attributes of each process, in their own memory locations. From 00014979@csse.uwa.edu.au Tue Oct 27 05:05:32 2015 Date: Tue Oct 27 05:05:32 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: Step 5 error From: "Christopher McDonald" X-smilie: none X-img: none "Joseph Thompson" <21517108@student.uwa.edu.au> wrote: > As you can see, the prompt is coming before all the output, and then no prompt is > coming after the output. This is completely normal, and there's nothing to fix. From 00014979@csse.uwa.edu.au Tue Oct 27 05:16:27 2015 Date: Tue Oct 27 05:16:27 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: Step 5 error From: "Christopher McDonald" X-smilie: none X-img: none "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> wrote: > Thus, (and I'm assuming here that you DID mean "ls &" instead of "ls" for the mysh.4 prompt) what > you are experiencing is quite normal, and even expected. To prove it, that's what the main > terminal does as well. I've attached an image proving this. I called the command "pwd &" from > bash, and it does exactly what your mysh (and my own) do: it prints the next prompt, then pwd > prints its result before I have a chance to input my next command sequence. Thus, when I enter the > next command, an echo command, there is no prompt before it, as the prompt was printed almost > immediately before pwd finished. Actually your example doesn't quite show what you're stating. Yes, the standard shell prints its next prompt before the background process completes, BUT the standard shells also monitor the termination of background processes (which our project doesn't have to) and then reports the background's termination and prints *another* prompt. From nelsoj07@csse.uwa.edu.au Tue Oct 27 06:20:29 2015 Date: Tue Oct 27 06:20:29 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.174.95 Subject: o.t From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none A little of column A, a little of column B :) A lot of it I think we've been taught directly, and the rest we've been shown how to learn, if that makes sense. This project has definitely been interesting in showing me gaps in my knowledge for sure! Also relevant: http://imgs.xkcd.com/comics/good_code.png From nelsoj07@csse.uwa.edu.au Tue Oct 27 06:52:57 2015 Date: Tue Oct 27 06:52:57 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.174.95 Subject: Step 9 - Scripts From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: exclaim.png X-img: none Hey guys, Am I correct in assuming that a script file must be marked as executable in order to run as a script? Or will a regular file also run? On bash it returns "Permission denied" if it is not marked as executable, which makes me think that our program should run the same way. From mcfald01@csse.uwa.edu.au Tue Oct 27 07:05:36 2015 Date: Tue Oct 27 07:05:36 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.165.231 Subject: Step 9 From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none So far I've been working on different ways to do this 1) naively just taking each line as a string command, but then I'm not sure how to turn it into a CMDTREE with the parser, which needs a file pointer 2) Trying to run a new mysh which takes input from the file instead of stdin. Runs, but doesn't seem to do anything. No idea how to debug without more knowledge of the parser(possibly also my lack of io knowledge) 3) Running something similar to mysh.c: while(!feof(stdin)) { CMDTREE *t = parse_cmdtree(stdin); if(t != NULL) { exitstatus = execute_cmdtree(t); free_cmdtree(t); } } Which runs (hooray!) but does a few strange things - prints mysh.x where x is the number it left off at the parent process. Makes sense since it's a child of the parent and retains that value. - doesn't print mysh.x for the first command, despite a call to the parser which has that string - doesn't read the last line of the script text file - prints another mysh where it was supposed to do the last line (but doesn't do any command), and then another one before exiting I read up on feof to try to explain this, which said that feof will reach the end of the file, try to read another line and then finally detect EOF after processing some undefined thing. That would explain the random line at the end, but it still baffles me why the last line is ignored. Hope to get some insight on how to go about fixing these 'bugs', or perhaps a little insight into the parser if the errors are unavoidable. Also if anyone else did this step a different way, I'd love to hear some suggestions! From graven01@csse.uwa.edu.au Tue Oct 27 07:07:17 2015 Date: Tue Oct 27 07:07:17 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: open() help From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none ..facepalm....sorry that makes it easy then. thank you From nelsoj07@csse.uwa.edu.au Tue Oct 27 07:50:51 2015 Date: Tue Oct 27 07:50:51 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.174.95 Subject: Step 9 From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Just a quick and dirty theory on why the last line is ignored ( unless there is a newline character there? ), but is it because that would have the same effect as you typing into the prompt for ./mysh and then not hitting enter but closing the window, causing it not to run without that newline character? I have the same "bugs" and "issues" as you do with my implementation for the most part, if that makes you feel any better. We still haven't figured out how to get the last extra lines to disappear either :? From hon06@csse.uwa.edu.au Tue Oct 27 08:44:47 2015 Date: Tue Oct 27 08:44:47 2015 To: help2002@csse.uwa.edu.au Received: from 110.143.115.203 Subject: Step 5 error From: "Nathan Ho" <21506898@student.uwa.edu.au> X-smilie: none X-img: none The sample output provided is for ls NOT ls &. The issue we are having is that whenever a background execution is run, all subsequent commands (whether they be background execution or just 'normal' commands), are of the form shown: mysh.x [command] mysh.(x+1) [command output displays here] Just to clarify is this expected or not? (ie. issues with normal commands after background execution) From nelsoj07@csse.uwa.edu.au Tue Oct 27 09:05:12 2015 Date: Tue Oct 27 09:05:12 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.174.95 Subject: Step 5 error From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none That's not the behaviour of the regular bash shell so I'd say that it's not expected. Open bash and test it out :) From hon06@csse.uwa.edu.au Tue Oct 27 09:24:14 2015 Date: Tue Oct 27 09:24:14 2015 Edit: Tue Oct 27 09:27:26 2015 To: help2002@csse.uwa.edu.au Received: from 110.143.115.203 Subject: Step 5 error From: "Nathan Ho" <21506898@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > That's not the behaviour of the regular bash shell so I'd say that it's not expected. > > Open bash and test it out :) Yeah, we are pretty aware that its not the expected output in the case of comparing it to the regular shell(hence the post haha...). Was just checking to see if Chris replied thinking it was ls & in our sample output, not ls (sorry if we made it unclear). From graven01@csse.uwa.edu.au Tue Oct 27 10:48:28 2015 Date: Tue Oct 27 10:48:28 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: step 7 From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none When i type in bash time ./testprogram > test.txt i only get the output of the testprogram and time gets printed to stdout mine writes the whole lot to the file, is this ok? intuitively i prefer it to write the whole thing, but i'm sure there are reasons why it wouldn't. From 00014979@csse.uwa.edu.au Tue Oct 27 11:01:42 2015 Date: Tue Oct 27 11:01:42 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: step 7 From: "Christopher McDonald" X-smilie: none X-img: none Better re-read the project sheet. From graven01@csse.uwa.edu.au Tue Oct 27 11:34:22 2015 Date: Tue Oct 27 11:34:22 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: step 7 From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none i see that it is to write to the stderr stream i guess I'm curious as to why, to what benefit? From 00014979@csse.uwa.edu.au Tue Oct 27 12:14:41 2015 Date: Tue Oct 27 12:14:41 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: o.t From: "Christopher McDonald" X-smilie: none X-img: none Some old RAM for sale: http://historical.ha.com/itm/explorers/gemini-3-flown-random-access-non-destructive-readout-4096-bit-memory-plane-from-the-gemini-spacecraft-computer/a/6146-52008.s?ic4=GalleryView-ShortDescription-071515 From graven01@csse.uwa.edu.au Tue Oct 27 12:24:16 2015 Date: Tue Oct 27 12:24:16 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: o.t From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none Nice, are you providing prizes for the best project ? if so ill just take the cash. From abusha02@csse.uwa.edu.au Tue Oct 27 13:18:48 2015 Date: Tue Oct 27 13:18:48 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.191.235 Subject: Step 5 error From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> wrote: > > > Thus, (and I'm assuming here that you DID mean "ls &" instead of "ls" for the mysh.4 prompt) what > > you are experiencing is quite normal, and even expected. To prove it, that's what the main > > terminal does as well. I've attached an image proving this. I called the command "pwd &" from > > bash, and it does exactly what your mysh (and my own) do: it prints the next prompt, then pwd > > prints its result before I have a chance to input my next command sequence. Thus, when I enter the > > next command, an echo command, there is no prompt before it, as the prompt was printed almost > > immediately before pwd finished. > > Actually your example doesn't quite show what you're stating. > > Yes, the standard shell prints its next prompt before the background process completes, > BUT the standard shells also monitor the termination of background processes (which our project doesn't have > to) and then reports the background's termination and prints *another* prompt. Really. I thought we had to do the same thing, and built in a new signal handler to deal with reaping terminated background processes. Are you saying this is unnecessary, and all we had to do was not call wait() in the case of a background process. If that is indeed the case, then we have over complicated this task enormously. We have successfully dealt with reaping background processes using a signal handler, but what we are having trouble with is cases where a sequence of commands is to be run in the background. For example, the command: ls && cal 2014 && cal 2015 & This command would require the entire sequence of 3 commands to be run in the background. Contrary to what you are saying in your post, though, the progress of these background processes does need to be monitored, as you shouldn't run cal 2014 unless ls exits successfully, and you shouldn't run cal 2015 unless cal 2014 exits successfully. But, you still have to run all 3 in the background, and still (somehow) prevent cal 2014 and cal 2015 from running unless their preceding command (which is also running in the background) exited successfully. Thus, we found that for such examples, there is definitely a requirement to monitor the progress and exit status of background processes. Given that my partner and I have devoted a lot of time to this particular issue, can I clarify now: what is the expectation with background processes? Are we required to solve complex sequences of commands, such as the above, and commands such as "ls & cal 2014 && cal 2015 &", and build in new signal handlers to deal with reaping terminated background processes? Or are we simply expected to be able to solve relatively simple sequences such as "ls &" and "ls & pwd", where only one command in the sequence of commands will run in the background? Before we waste more time over complicating this task, could you please clarify the requirement? From 00014979@csse.uwa.edu.au Tue Oct 27 13:29:00 2015 Date: Tue Oct 27 13:29:00 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Step 5 error From: "Christopher McDonald" X-smilie: none X-img: none "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> wrote: > Really. I thought we had to do the same thing, and built in a new signal handler to deal with reaping terminated > background processes. Are you saying this is unnecessary, and all we had to do was not call wait() in the case of If a new signal handler was required, the signal() function or other similar functions would have been mentioned in the list of "Helpful functions" at the end of the background step. It's great that you've addressed the issue, but it wasn't required. > For example, the command: > ls && cal 2014 && cal 2015 & > > This command would require the entire sequence of 3 commands to be run in the background. Contrary to what you > are saying in your post, though, the progress of these background processes does need to be monitored, as you > shouldn't run cal 2014 unless ls exits successfully, and you shouldn't run cal 2015 unless cal 2014 exits > successfully. But, you still have to run all 3 in the background, and still (somehow) prevent cal 2014 and cal > 2015 from running unless their preceding command (which is also running in the background) exited successfully. > Thus, we found that for such examples, there is definitely a requirement to monitor the progress and exit status > of background processes. Not contrary at all. When you look at this example in the web-based program, you'll see that the original parent just forks the new child for the background sequence, but then the original parent can just forget about whatever will be done in the background. Yes, the child then has to monitor the sequence of &&s, but the original parent doesn't. From abusha02@csse.uwa.edu.au Tue Oct 27 14:02:40 2015 Date: Tue Oct 27 14:02:40 2015 Edit: Tue Oct 27 14:02:52 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.191.235 Subject: Step 5 error From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none Thanks Chris. Turns out my approach was a little off, and your comment helped me understand how background actually works. I've got it working perfectly now. Much appreciated. From lopasb03@csse.uwa.edu.au Tue Oct 27 14:31:11 2015 Date: Tue Oct 27 14:31:11 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step 9 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Hi, I have read the comments people are saying about step 9, and it seems they are doing something way different to what I have done, for this reason I would like to get some clarification on how this step is supposed to work. For example, in my present working directory (pwd) I have made a shell script called "ben.sh" with some commands in it, purely for testing purposes. In my execute_command function I have put a segment of code that does the following: If all my attempts to open "ben.sh" fail with the execv requests I have made, I have put in an if statement that says if all the previous attempts at opening "ben.sh" fail, that I should take the following approach to the command: first I fork a new process called "mysh3" for example, then I add the "./" characters to "ben.sh", which gives me a command "./ben.sh" to run within my shell. So then I simply execv my new command "./ben.sh" and the shell executes the shell script. Is this what we are supposed to do? If not, could somebody please point me in the right direction. I also had another theory about what this step is asking, ie. fopen the shell script then read every line from within the script and execute the shell script line by line from the shell, however that seemed a bit ridiculous to me. Any comments/suggestions on this step would be greatly appreciated. Many Thanks, Ben. c",) From hon06@csse.uwa.edu.au Tue Oct 27 15:29:59 2015 Date: Tue Oct 27 15:29:59 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.113.216 Subject: Step 7 Query From: "Nathan Ho" <21506898@student.uwa.edu.au> X-smilie: none X-img: none Can we assume when a subshell has infiles or outfiles, that the directory is not changed within the subshell? I know this isn't the case in the real shell, however for example, if we have a subshell and cd within the subshell (ie. (cd; ls ; ps) > test2) this becomes messy to handle at least in our code (real shell puts test2 in the old working directory, it doesn't care the subshell has changed directory). This is further complicated as there are several options for path names (ie. /test/file abs paths, test/file relative paths, ./, ../, -/, ~/). From nelsoj07@csse.uwa.edu.au Tue Oct 27 15:44:09 2015 Date: Tue Oct 27 15:44:09 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: Step 9 From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none From a glance, will your solution for Step 9 work if the script is not in your current directory? From my understanding it should look for it in each of the paths in your PATH directory. From newmal01@csse.uwa.edu.au Tue Oct 27 15:47:14 2015 Date: Tue Oct 27 15:47:14 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: setenv() From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none im am trying to use the setenv() function to set the new enviromental variable here is a test case ---------------------------------------------------------------------------- #include "mysh.h" #include #include int main(int argc, char *argv[]){ char *p="GOOD ONE"; setenv("PATH",p,0); printf("%s\n",PATH); } ------------------------------------------------------------------------------ howevver i am recieving the error iplicit delaration of function setenv() even though we i use man setenv the function is included in the header From nelsoj07@csse.uwa.edu.au Tue Oct 27 15:53:33 2015 Date: Tue Oct 27 15:53:33 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: setenv() From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Do you need to use setenv()? Can you just execute it effectively as if it is an internal command, and set the PATH variable (or HOME or CDPATH) with a string function? :) From lopasb03@csse.uwa.edu.au Tue Oct 27 16:20:40 2015 Date: Tue Oct 27 16:20:40 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: Step 9 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > From a glance, will your solution for Step 9 work if the script is not in your current > directory? From my understanding it should look for it in each of the paths in your PATH > directory. Don't you mean that the script will work if it *is* in my current directory, because that's where it is. My program already tries to run the "ben.sh" file by adding the four PATH path's to the file name. For example it will try to run from PATH firstly /bin/ben.sh, but that doesn't work. This is the same as the case for /usr/bin/ben.sh, and the CDPATH options such as .ben.sh or ..ben.sh . Once all these execv have failed, ie returned -1, my new for step 9 simply adds "./" to "ben.sh", which allows the program to run from where it is in the present working directory. I think this is how it would work in a regular bash shell as well. It really doesn't make sense to search all of those path's given to us by PATH and CDPATH, for the ben.sh file. It is up to the user to get to the directory the file is located in and then simply type the shell script name. Maybe Chris can shed some light on whether this approach I have taken to step 9 is the correct logic. Thanks Again For your input Jake, cheers, Ben. c",) From 00014979@csse.uwa.edu.au Tue Oct 27 16:55:30 2015 Date: Tue Oct 27 16:55:30 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: setenv() From: "Christopher McDonald" X-smilie: none X-img: none Jake's suggestion is correct; you will not need setenv() - just modify one of mysh's 3 internal variables. From 00014979@csse.uwa.edu.au Tue Oct 27 16:57:46 2015 Date: Tue Oct 27 16:57:46 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Step 7 Query From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Can we assume when a subshell has infiles or outfiles, that the directory is not > changed within the subshell? You should not, and do not, need to assume this. If you correctly perform your file I/O redirection *before* you consider what to do for your subshell, then you "don't care" what your subshell does. From hon06@csse.uwa.edu.au Tue Oct 27 17:13:13 2015 Date: Tue Oct 27 17:13:13 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.113.216 Subject: Step 5 error From: "Nathan Ho" <21506898@student.uwa.edu.au> X-smilie: none X-img: none Just to note, the OP and I are still having issues with normal commands printing on the next line if we have previously executed background commands, so any help would be appreciated :). Sorry, I thought this thread got a little sidetracked... From bradfj01@csse.uwa.edu.au Tue Oct 27 17:20:48 2015 Date: Tue Oct 27 17:20:48 2015 To: help2002@csse.uwa.edu.au Received: from 49.196.11.137 Subject: Subshell From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none Just slightly confused with step 6 - subshell. I'm under the assumption that we are forking the entire shell and executing commands as per normal but in the forked shell which is the subshell. From bradfj01@csse.uwa.edu.au Tue Oct 27 17:22:59 2015 Date: Tue Oct 27 17:22:59 2015 To: help2002@csse.uwa.edu.au Received: from 49.196.11.137 Subject: Subshell From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none Don't know why I posted that as anonymous, it must've been automatically done. From newmal01@csse.uwa.edu.au Tue Oct 27 17:44:02 2015 Date: Tue Oct 27 17:44:02 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: setenv() From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: ok i understand i am still curious though why this error is occuring? From lopasb03@csse.uwa.edu.au Tue Oct 27 20:55:25 2015 Date: Tue Oct 27 20:55:25 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.202.199 Subject: setenv() From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > Jake's suggestion is correct; > you will not need setenv() - just modify one of mysh's 3 internal variables. Well I thought step ten would be harder than it was, but can you confirm with me just so I can be sure that this is what need to be done for path: Firstly I checked that t->argv[0] == set and t->argv[1] == PATH , then I fork off and allow the user to change the PATH by typing set PATH "new paths" at the prompt, where new paths are the paths separated by semi colons. Is this is as simple as it is, I expected step 10 to be harder than the previous steps, personally I found step 8 the hardest. Let me know what you think, any comments or suggestions that can help me will be appreciated. Cheers, Ben. c",) From liaoj02@csse.uwa.edu.au Tue Oct 27 21:04:54 2015 Date: Tue Oct 27 21:04:54 2015 To: help2002@csse.uwa.edu.au Received: from 43.252.114.29 Subject: Step 8 confusion From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > If you have a command in the form: > > a | b | c > > Then you have two pipe nodes total. Your first pipe node (or topmost in the tree, not sure of phrasing) has a left and > right pointer to other cmd_tree nodes. On the left is a command node and on the right another pipe command. > > My pseudo code version of execute_cmdtree will run on the top most node and recognising that it's a pipe, call the function > run_pipe. This will "do pipey stuff" and then call execute_cmdtree again for the left and right nodes. For the left node > this will recognise that it is a command node and do the command "a" . For the right node, it will recognise that it is a > pipe_node and again call execute_cmdtree again for the left and right nodes. For the left node this will recognise that it > is a command node and do the command "b" and then the right node will do the command "c". > > Does that make sense? Obviously the "do pipey stuff" needs to work, but then it should just be a call or function that can > be used again if or when needed. > > The same form would work no matter how many pipes are needed, with the same amount of code. > > Go to this url: https://secure.csse.uwa.edu.au/run/cmdtree and try the sequence a | b | c to see visually what I mean in > terms of the node relationships. Hi Jake. If the command is such that internal | external2 | external3, because the first command is internal, the pipe just need to be closed at it's write end and redirect to the external2 's read end. However, for external2 there will be a fork(); should I pipe the child process's stdout to external3's stdin or I need to first pipe it back to parent's stdin and then through the parent's stdout to pass the info to external3? Thanks From newmal01@csse.uwa.edu.au Tue Oct 27 21:07:06 2015 Date: Tue Oct 27 21:07:06 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: step 9 and step 10 From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none I have currently only coded within the execute.c file for steps 1 to 8 but im just wondering for the final to is it recommended to implement them by changing or extending the code in one of the other files? From lis63@csse.uwa.edu.au Tue Oct 27 21:13:22 2015 Date: Tue Oct 27 21:13:22 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.221.171 Subject: Subshell execution and step 7 (all parts) From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > I have implemented a solution for all parts of step 7, however, my program does not > work if I have a subshell as one of the commands. I wonder if anyone else is having > this problem, I have spent hours trying to redirect the stdout of my subshell to > another file, but as it is I have not even come close. > > Is there a trick to implementing the subshell's stdout output or the stdin input? > Any tips/comments or suggestions that can help me would be greatly appreciated. > > Thanks. :) It happened to me before, and now I fix it. There is nothing special about the subshell, just run the code of redirecting before the code of subshell and don't forget to reset stdin and stdout From tans121@csse.uwa.edu.au Tue Oct 27 21:49:06 2015 Date: Tue Oct 27 21:49:06 2015 To: help2002@csse.uwa.edu.au Received: from 58.110.164.36 Subject: Step 9 - Scripts From: "Shao-Ming Tan" <20920822@student.uwa.edu.au> X-smilie: none X-img: none I just put a check to see if user had execution permissions with X_OK From mcfald01@csse.uwa.edu.au Tue Oct 27 23:52:21 2015 Date: Tue Oct 27 23:52:21 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.160.175 Subject: step 9 and step 10 From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none My current full solution uses: mysh.c, parser.c, globals.c (unchanged) execute.c internals.c execute_cmd.c fileIO.c script.c and of course all stuff that needs to be linked across multiple parts is defined in mysh.h While it is possible to do everything in 1 file, I think it's better practice to break up steps into different files, which can be a new and not necessarily one of the ones given. From liaoj02@csse.uwa.edu.au Wed Oct 28 00:06:23 2015 Date: Wed Oct 28 00:06:23 2015 Edit: Wed Oct 28 00:07:04 2015 To: help2002@csse.uwa.edu.au Received: from 43.252.114.29 Subject: Step 8 .. From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Hi. I am not sure if my understanding of piping is right here. So just list some scenarios and feel free to comment my mistakes 1. does it matter if the command is internal or external? From the online manual, it says the child inherit the parents file description. As a result, if the child's process 's stdout is connected to the pipe, then I dont need to do it for parent? Or is it the other way around? 2. for the each case I need to connect stdout to the pipe[1](write end) or pipe[0]? Cuz I though the output of a command goes in the read end of the next cmd? Or the first pipe is a broken one which uses the write side only.. A ---> Pw -----> Pr --->B ---> Pw Is my illustration right here? then what happen to the Pr for process A? Do I just close it? THanks From bullof01@csse.uwa.edu.au Wed Oct 28 03:33:35 2015 Date: Wed Oct 28 03:33:35 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.236 Subject: Invalid Trees? From: "Fraser Bullock" <21299527@student.uwa.edu.au> X-smilie: wassat.png X-img: none Should the following commands be considered invalid/beyond the scope of the assignment? a & | b (pipe from an async) a | & b (pipe to an async) a | | b (pipe line, through a null, basically pointless?) These produce weird trees. And if these are not a valid command, would it be a good idea coding to effectively ignore a pipe leaf if it's left/right is null, preventing a crash? if they are valid, what about: && b a && || b a || a && && b b && || b etc From bullof01@csse.uwa.edu.au Wed Oct 28 03:46:17 2015 Date: Wed Oct 28 03:46:17 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.236 Subject: Step 8 .. From: "Fraser Bullock" <21299527@student.uwa.edu.au> X-smilie: none X-img: none think of your pipe as being like this command: a > temp && b < temp ; rm temp a outputs to a file named temp, b inputs from a file named temp, we delete the file named temp the pipe should do this internally (without creating any files*) From 00014979@csse.uwa.edu.au Wed Oct 28 04:27:17 2015 Date: Wed Oct 28 04:27:17 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: Subshell From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Just slightly confused with step 6 - subshell. I'm under the assumption that we are > forking the entire shell and executing commands as per normal but in the forked shell > which is the subshell. Yes; what's your confusion? From 00014979@csse.uwa.edu.au Wed Oct 28 04:29:07 2015 Date: Wed Oct 28 04:29:07 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: setenv() From: "Christopher McDonald" X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > Firstly I checked that t->argv[0] == set and t->argv[1] == PATH , then I fork > off and allow the user to change the PATH by typing set PATH "new paths" at the > prompt, where new paths are the paths separated by semi colons. Better re-read the project sheet, particularly the bit: "For example set PATH .:/bin:/usr/local/bin " From 00014979@csse.uwa.edu.au Wed Oct 28 04:37:08 2015 Date: Wed Oct 28 04:37:08 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: setenv() From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > im am trying to use the setenv() function to set the new enviromental variable > here is a test case > ---------------------------------------------------------------------------- > #include "mysh.h" > #include > #include > > int main(int argc, char *argv[]){ > char *p="GOOD ONE"; > setenv("PATH",p,0); > > printf("%s\n",PATH); > } > ------------------------------------------------------------------------------ > howevver i am recieving the error iplicit delaration of function setenv() > even though we i use man setenv the function is included in the header The above code compiles under OS-X, because setenv() is conditionally prototyped in , but under Linux (which you seem to be using), you'll need to add #define _BSD_SOURCE before your #include . It's not a standard C99 function, but one belonging to an OS standard. The setenv() function does not work as you appear to think it does. It does not permit you to change a variable's value by providing the variable's name as a string. This, while the above code will run successfully, it will *not* change the value of your PATH variable. From 00014979@csse.uwa.edu.au Wed Oct 28 04:39:07 2015 Date: Wed Oct 28 04:39:07 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: Step 9 - Scripts From: "Christopher McDonald" X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > Hey guys, > > Am I correct in assuming that a script file must be marked as executable in order to run as > a script? Or will a regular file also run? On bash it returns "Permission denied" if it is > not marked as executable, which makes me think that our program should run the same way. Yes .... our program should run the same way. From 00014979@csse.uwa.edu.au Wed Oct 28 04:46:59 2015 Date: Wed Oct 28 04:46:59 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: Invalid Trees? From: "Christopher McDonald" X-smilie: none X-img: none "Fraser Bullock" <21299527@student.uwa.edu.au> wrote: > Should the following commands be considered invalid/beyond the scope of the > assignment? Now you're picking on my parser! which, admittedly, isn't very robust in detecting invalid sequences. Given time, it'd be relatively easy to extend it, but I obviously won't do that at this stage. Just focus on the clearly correct cases (now waiting for the flood of followup questions about what that means :-). We won't be testing your projects with any strange sequences. From 00014979@csse.uwa.edu.au Wed Oct 28 05:45:31 2015 Date: Wed Oct 28 05:45:31 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: Step 5 error From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Just to note, the OP and I are still having issues with normal commands printing on the next line if we have previously executed > background commands, so any help would be appreciated :). Your problem only sounds like a coding problem in your handling of certain types of NODETYPE: - if it's a N_COMMAND, then the parent waits for the child to finish and, thus, the next prompt will only appear when the child process has terminated and finished producing its output. - if it's a N_BACKGROUND, then it's quite OK (it's anticipated) that the next prompt with be printed (by the parent process) before or 'within' the output of the child process. From 00014979@csse.uwa.edu.au Wed Oct 28 05:47:31 2015 Date: Wed Oct 28 05:47:31 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: step 7 From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > i see that it is to write to the stderr stream i guess I'm curious as to why, to what benefit? By writing to stderr, the timing information won't be redirected to a file, and the eventual output captured to the file won't be 'polluted' by the timing information. A commonly used sequence is: time program-being-evaluated > /dev/null From nelsoj07@csse.uwa.edu.au Wed Oct 28 06:30:30 2015 Date: Wed Oct 28 06:30:30 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.19.247 Subject: Step 9 - Scripts From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Thanks guys, makes sense :) From nelsoj07@csse.uwa.edu.au Wed Oct 28 06:34:55 2015 Date: Wed Oct 28 06:34:55 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.19.247 Subject: setenv() From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Hey Ben, Does changing the PATH with your command stay in effect until you shut that instance of ./mysh? If you're forking it sounds like only the child process would have it's PATH changed. Just a heads up :) For what it's worth to answer your other question I didn't find Step 10 to be the most challenging either, a toss up between 7, 8 or 9 for me! From nelsoj07@csse.uwa.edu.au Wed Oct 28 06:38:03 2015 Date: Wed Oct 28 06:38:03 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.19.247 Subject: step 9 and step 10 From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none From memory I think Chris said that it could be done either way, it might depend on your reasoning for why or how your logic works. We're quite* close to being finished and it's currently still all in execute.c, so I'm not sure it matters :) From nelsoj07@csse.uwa.edu.au Wed Oct 28 06:45:38 2015 Date: Wed Oct 28 06:45:38 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.19.247 Subject: Step 8 confusion From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none If you call your code to handle pipes and change the necessary stdin and stdout streams as required at the node, then anything that's flowing on from there will inherit those descriptors, as child processes inherit their stdin and stdout of their parents. So if you do need to fork in any of the nodes then the child created should still be piping it's output to the right place, be it a file or another programs stdin stream. So the child should inherit it's parent's stdin and stdout, so it should pass the info on to external3 automagicallly :) From 00014979@csse.uwa.edu.au Wed Oct 28 08:30:48 2015 Date: Wed Oct 28 08:30:48 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: step 9 and step 10 From: "Christopher McDonald" X-smilie: none X-img: none Yes, gets lost: https://secure.csse.uwa.edu.au/run/help2002?p=np&a=845 From liaoj02@csse.uwa.edu.au Wed Oct 28 08:43:34 2015 Date: Wed Oct 28 08:43:34 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.126.6 Subject: Step 8 .. From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none ohh. so each pipe should be identical then..have two ends. but should b's output be connected back to stdout? From graven01@csse.uwa.edu.au Wed Oct 28 09:06:09 2015 Date: Wed Oct 28 09:06:09 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: global file variables From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none i'm trying to clean up my code and place thing more "neatly" when i shift my inf and otf (infile and outfile) variables to mysh.h i get the following when i "make" the file Undefined symbols for architecture x86_64: "_inf", referenced from: _execute_cmdtree in execute.o "_otf", referenced from: _execute_cmdtree in execute.o ld: symbol(s) not found for architecture x86_64 they are essentially just ints that index a file descriptor. I'm not sure why i am getting this error ? From lopasb03@csse.uwa.edu.au Wed Oct 28 09:57:11 2015 Date: Wed Oct 28 09:57:11 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.175.185 Subject: setenv() From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > > > Firstly I checked that t->argv[0] == set and t->argv[1] == PATH , then I fork > > off and allow the user to change the PATH by typing set PATH "new paths" at the > > prompt, where new paths are the paths separated by semi colons. > > Better re-read the project sheet, particularly the bit: > > "For example set PATH .:/bin:/usr/local/bin " Yeah, of course I didn't set PATH to "new paths" I set it to .:/bin:/usr/local/bin is that the correct way to execute step 10 though, I am still uncertain if this method that I have used is the correct way to implement a change for the PATH variable for example? From lopasb03@csse.uwa.edu.au Wed Oct 28 10:02:54 2015 Date: Wed Oct 28 10:02:54 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.175.185 Subject: Step 9 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > > > From a glance, will your solution for Step 9 work if the script is not in your current > > directory? From my understanding it should look for it in each of the paths in your PATH > > directory. > > Don't you mean that the script will work if it *is* in my current directory, because that's > where it is. My program already tries to run the "ben.sh" file by adding the four PATH path's > to the file name. > > For example it will try to run from PATH firstly /bin/ben.sh, but that > doesn't work. This is the same as the case for /usr/bin/ben.sh, and the CDPATH options > such as .ben.sh or ..ben.sh . Once all these execv have failed, ie returned -1, my new > for step 9 simply adds "./" to "ben.sh", which allows the program to run from where it is > in the present working directory. > > I think this is how it would work in a regular bash shell as well. It really doesn't make sense > to search all of those path's given to us by PATH and CDPATH, for the ben.sh file. It is > up to the user to get to the directory the file is located in and then simply type the > shell script name. Maybe Chris can shed some light on whether this approach I have taken to > step 9 is the correct logic. > > Thanks Again For your input Jake, cheers, Ben. c",) Can somebody please verify that this is the correct method for step 9, thankyou. :) From lopasb03@csse.uwa.edu.au Wed Oct 28 10:07:03 2015 Date: Wed Oct 28 10:07:03 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.175.185 Subject: setenv() From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > Hey Ben, > > Does changing the PATH with your command stay in effect until you shut that instance of > ./mysh? If you're forking it sounds like only the child process would have it's PATH > changed. Just a heads up :) > > For what it's worth to answer your other question I didn't find Step 10 to be the most > challenging either, a toss up between 7, 8 or 9 for me! I'm not a 100% on this answer, but when I fork and set a new path the whole new process will have its PATH changed, so it shouldn't matter to the user that it is only the child process that has changed? But I am not sure, could somebody please clarify this for both mine and Jakes sake. Thankyou, Ben. c",) From newmal01@csse.uwa.edu.au Wed Oct 28 10:36:26 2015 Date: Wed Oct 28 10:36:26 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: setenv() From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > "Christopher McDonald" wrote: > > > Well I thought step ten would be harder than it was, but can you confirm with me > just so I can be sure that this is what need to be done for path: > > Firstly I checked that t->argv[0] == set and t->argv[1] == PATH , then I fork > off and allow the user to change the PATH by typing set PATH "new paths" at the > prompt, where new paths are the paths separated by semi colons. > > Is this is as simple as it is, I expected step 10 to be harder than the previous > steps, personally I found step 8 the hardest. Let me know what you think, any > comments or suggestions that can help me will be appreciated. > > Cheers, Ben. c",) Hey mate i have done exactly almost exactly the same thing as you for step 10 but i have just made it so the user provides the new value for whatever(PATH,HOME CDPATH) within the command line however im having problems for some reason the value of whatever will not hold in the next instance here is an example: mysh1:set HOME /home HOME: /home PATH: (original value) CDPATH: (original value) mysh2:set PATH /path HOME: set PATH: /path CDPATH: (orignal value) mysh3: set CDPATH /cdpath HOME: /cdpath PATH: set CDPATH: /cdpath From lopasb03@csse.uwa.edu.au Wed Oct 28 10:50:31 2015 Date: Wed Oct 28 10:50:31 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.175.185 Subject: setenv() From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > Hey mate i have done exactly almost exactly the same thing as you for step 10 > but i have just made it so the user provides the new value for whatever(PATH,HOME > CDPATH) within the command line > however im having problems for some reason the value of whatever will not hold in the > next instance > > here is an example: > > mysh1:set HOME /home > > HOME: /home > PATH: (original value) > CDPATH: (original value) > > mysh2:set PATH /path > HOME: set > PATH: /path > CDPATH: (orignal value) > > mysh3: set CDPATH /cdpath > HOME: /cdpath > PATH: set > CDPATH: /cdpath I don't know if this means anything, and I havn't actually tested it yet, but I get the user to type "set PATH .:/bin:/usr/local/bin" and that seems to work when I print out the value of PATH in the next instance? I will do some more testing and get back to you. c",) From lopasb03@csse.uwa.edu.au Wed Oct 28 11:05:54 2015 Date: Wed Oct 28 11:05:54 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.175.185 Subject: setenv() From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > ANONYMOUS wrote: > > > Hey mate i have done exactly almost exactly the same thing as you for step 10 > > but i have just made it so the user provides the new value for whatever(PATH,HOME > > CDPATH) within the command line > > however im having problems for some reason the value of whatever will not hold in the > > next instance > > > > here is an example: > > > > mysh1:set HOME /home > > > > HOME: /home > > PATH: (original value) > > CDPATH: (original value) > > > > mysh2:set PATH /path > > HOME: set > > PATH: /path > > CDPATH: (orignal value) > > > > mysh3: set CDPATH /cdpath > > HOME: /cdpath > > PATH: set > > CDPATH: /cdpath > > > I don't know if this means anything, and I havn't actually tested it yet, but I get the > user to type "set PATH .:/bin:/usr/local/bin" and that seems to work when I print out the > value of PATH in the next instance? I will do some more testing and get back to you. c",) Hey Anonymous,I just tested my method and it works perfectly, just thought I'd give you a heads up. c",) From lis63@csse.uwa.edu.au Wed Oct 28 11:08:46 2015 Date: Wed Oct 28 11:08:46 2015 To: help2002@csse.uwa.edu.au Received: from 180.216.42.56 Subject: How to deal with "time (cal;ls)" From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none Hi! When I input "time (cal;ls" into a standard shell, it works. However, When I input it into https://secure.csse.uwa.edu.au/run/cmdtree, I get nothing. Does it mean we don't need to worry about such inputs? I went over the instruction but didn't find any hints about it. From 00014979@csse.uwa.edu.au Wed Oct 28 11:09:02 2015 Date: Wed Oct 28 11:09:02 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: global file variables From: "Christopher McDonald" X-smilie: none X-img: none "Nathan Graves" <21256779@student.uwa.edu.au> wrote: > they are essentially just ints that index a file descriptor. I'm not sure why i am getting > this error ? Track down how the other (provided) global variables are 'presented' in the starting code. Remember that global variables need to be both declared and defined (possibly in different places). From 00014979@csse.uwa.edu.au Wed Oct 28 12:12:30 2015 Date: Wed Oct 28 12:12:30 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: How to deal with "time (cal;ls)" From: "Christopher McDonald" X-smilie: none X-img: none Not required. See the bottom of: https://secure.csse.uwa.edu.au/run/help2002?p=np&a=826 From nelsoj07@csse.uwa.edu.au Wed Oct 28 12:22:46 2015 Date: Wed Oct 28 12:22:46 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: Step 9 From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Ah ok, gotcha. Does it work if the file is named without an extension? That's one way I'd try and test your implementation :) From nelsoj07@csse.uwa.edu.au Wed Oct 28 12:29:14 2015 Date: Wed Oct 28 12:29:14 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: Step 8 .. From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none For a | b stdin(a) = keyboard (default) stdout(a) = piped to stdin(b) stdout(b) = screen (default) Program a is going to do whatever asked of it, while b is going to read in a's output and then output to the default stdout the screen. So ls | sort executes ls and sends the output to sort, which then outputs to the screen. Does that make sense at all? :) From 00014979@csse.uwa.edu.au Wed Oct 28 12:50:12 2015 Date: Wed Oct 28 12:50:12 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: setenv() From: "Christopher McDonald" X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > I'm not a 100% on this answer, but when I fork and set a new path the whole new process > will have its PATH changed, so it shouldn't matter to the user that it is only the child Like those of Step 3, 'set' is (must be) an internal command. From lis63@csse.uwa.edu.au Wed Oct 28 13:36:28 2015 Date: Wed Oct 28 13:36:28 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.221.171 Subject: How to deal with "time (cal;ls)" From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > Not required. > See the bottom of: https://secure.csse.uwa.edu.au/run/help2002?p=np&a=826 Thank you. Good news! From lopasb03@csse.uwa.edu.au Wed Oct 28 13:55:01 2015 Date: Wed Oct 28 13:55:01 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.175.185 Subject: setenv() From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > > > I'm not a 100% on this answer, but when I fork and set a new path the whole new process > > will have its PATH changed, so it shouldn't matter to the user that it is only the child > > Like those of Step 3, 'set' is (must be) an internal command. That's exactly what I have done Chris, thanks for the clarification. :) From lopasb03@csse.uwa.edu.au Wed Oct 28 13:58:56 2015 Date: Wed Oct 28 13:58:56 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.175.185 Subject: Step 9 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > Ah ok, gotcha. Does it work if the file is named without an extension? That's one way I'd try and test your > implementation :) I am pretty sure that we don't need to open a file without an extension,I think the file should already have the extension on it, as the project sheet says: "No specific filename extension is required" ,so it could be any type of text file, like a .txt , .sh , and so on, so we shouldn't have to account for that. c",) From lis63@csse.uwa.edu.au Wed Oct 28 14:17:57 2015 Date: Wed Oct 28 14:17:57 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.221.171 Subject: How to deal with "time (cal;ls)" From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > Not required. > See the bottom of: https://secure.csse.uwa.edu.au/run/help2002?p=np&a=826 Hi, now I'm wondering if we are required to do things like "time shell_script". From abusha02@csse.uwa.edu.au Wed Oct 28 14:29:26 2015 Date: Wed Oct 28 14:29:26 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.191.235 Subject: Some final clarifications From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none Pretty much finished, just have a few clarifications: 1. Are we supposed to submit every file individually, or can we just submit a .zip? 2. With stuff like 'time', we just print "execution time: xxx microseconds". Is this acceptable, or is there a specific format required? 3. Since we reap background processes when they're finished, we print out something like "reaped process id xxx" when a process is reaped. Should we get rid of this (i.e. will it confuse the auto marker), or can we just keep it in (since we thought it was good that we got a signal handler working for background processes, and didn't want to scrap it just cause it wasn't a requirement) From 00014979@csse.uwa.edu.au Wed Oct 28 15:15:09 2015 Date: Wed Oct 28 15:15:09 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Step 9 From: "Christopher McDonald" X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > Can somebody please verify that this is the correct method for step 9, thankyou. :) I think you should re-read the project sheet: - a shellscript could exist in any of the directories in your PATH - there's no specific filename extension required - there's nothing stated about specifically looking for the shellscript in the current directory - shellscript execution has nothing to do with CDPATH From 00014979@csse.uwa.edu.au Wed Oct 28 15:15:40 2015 Date: Wed Oct 28 15:15:40 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: How to deal with "time (cal;ls)" From: "Christopher McDonald" X-smilie: none X-img: none "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > Hi, now I'm wondering if we are required to do things like "time shell_script". Yes (why not?) From lis63@csse.uwa.edu.au Wed Oct 28 15:48:15 2015 Date: Wed Oct 28 15:48:15 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.221.171 Subject: How to deal with "time (cal;ls)" From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > > > Hi, now I'm wondering if we are required to do things like "time shell_script". > > Yes (why not?) Thank you! WOW! I need to rewrite many functions!! From 00014979@csse.uwa.edu.au Wed Oct 28 16:00:39 2015 Date: Wed Oct 28 16:00:39 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: How to deal with "time (cal;ls)" From: "Christopher McDonald" X-smilie: none X-img: none "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > WOW! I need to rewrite many functions!! Surely not! Unless you're not considering shellscripts to be almost identical to standard commands. Can you execute: time time date time time time time time time date ? From nelsoj07@csse.uwa.edu.au Wed Oct 28 16:05:14 2015 Date: Wed Oct 28 16:05:14 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: How to deal with "time (cal;ls)" From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Would that give us multiple readings for time? Executing: time time time date would give something like: Wed 28 Oct 2015 16:03:33 AWST 4.948975msec 4.954102msec 4.957764msec From 00014979@csse.uwa.edu.au Wed Oct 28 16:11:02 2015 Date: Wed Oct 28 16:11:02 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: How to deal with "time (cal;ls)" From: "Christopher McDonald" X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > Would that give us multiple readings for time? Yes, but you'll be printing: 4msec 4msec 4msec ?? From nelsoj07@csse.uwa.edu.au Wed Oct 28 16:14:51 2015 Date: Wed Oct 28 16:14:51 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: How to deal with "time (cal;ls)" From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Gotcha, thanks Chris :) From lopasb03@csse.uwa.edu.au Wed Oct 28 16:37:50 2015 Date: Wed Oct 28 16:37:50 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.175.185 Subject: Step 9 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > > > Can somebody please verify that this is the correct method for step 9, thankyou. :) > > I think you should re-read the project sheet: > > - a shellscript could exist in any of the directories in your PATH > - there's no specific filename extension required > - there's nothing stated about specifically looking for the shellscript in the current directory > - shellscript execution has nothing to do with CDPATH Oh, ok thanks for getting back to me, it seems I will have to make some changes then. Thanks, Ben. :) From coopea04@csse.uwa.edu.au Wed Oct 28 17:09:02 2015 Date: Wed Oct 28 17:09:02 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.121 Subject: Regarding exit stati From: "Adrian Cooper" <20786307@student.uwa.edu.au> X-smilie: none X-img: none Is a viable exist status, and if exit is called with it as the argument should it fail to exit or exit with some other exit status? From nelsoj07@csse.uwa.edu.au Wed Oct 28 17:14:59 2015 Date: Wed Oct 28 17:14:59 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: Regarding exit stati From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none From the Project guide: When an additional argument is provided, it should be interpreted as the numeric exit-status I'd interpret this to mean that only numeric characters are valid, and bash seems to back this up. Try opening bash and typing exit junk Hope that helps! :) From coopea04@csse.uwa.edu.au Wed Oct 28 19:11:33 2015 Date: Wed Oct 28 19:11:33 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.123 Subject: step 4 , where to go? From: "Adrian Cooper" <20786307@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > How (or where) do I access the information that record whether mine input commands have > > those special symbols? Is it (t->NODETYPE)?Moreover, are those types defined as a boolean > > value or a symbols in strc NODETYPE? > > > It seriously sounds like you have not used the webpage to display the parsed CMDTREE structure: > > https://secure.csse.uwa.edu.au/run/help2002?p=np&a=824&all=y2 Is the link meant to have something to do with the webpage? From lopasb03@csse.uwa.edu.au Wed Oct 28 19:58:41 2015 Date: Wed Oct 28 19:58:41 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.175.185 Subject: Step 9 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > "Christopher McDonald" wrote: > > > "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > > > > > Can somebody please verify that this is the correct method for step 9, thankyou. :) > > > > I think you should re-read the project sheet: > > > > - a shellscript could exist in any of the directories in your PATH > > - there's no specific filename extension required > > - there's nothing stated about specifically looking for the shellscript in the current directory > > - shellscript execution has nothing to do with CDPATH > > Oh, ok thanks for getting back to me, it seems I will have to make some changes then. Thanks, Ben. :) OK, I have spent the last couple of hours trying to understand what is going on in step 9, can somebody please break step 9 down into steps, so I know what I actually have to do, because at the moment I'm stumped, and the project is due in less than 48 hours :o From ahmedm07@csse.uwa.edu.au Wed Oct 28 20:23:19 2015 Date: Wed Oct 28 20:23:19 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.56.82 Subject: Step 7 - Error while opening file From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none Hey, So i am trying to figure out Step 7 and its driving me a little insane. What i am basically doing is opening a a file. Using O_CREAT as a flag. However, when this specific command runs it returns a value of -1. That shows that i have messed up somewhere but i cant figure out what i did wrong. I am pretty confused right now. Anyone got any ideas? From liaoj02@csse.uwa.edu.au Wed Oct 28 20:29:31 2015 Date: Wed Oct 28 20:29:31 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.126.138 Subject: Step 8 .. From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > For a | b > > stdin(a) = keyboard (default) > stdout(a) = piped to stdin(b) > stdout(b) = screen (default) > > Program a is going to do whatever asked of it, while b is going to read in a's output and > then output to the default stdout the screen. > > So ls | sort > > executes ls and sends the output to sort, which then outputs to the screen. > > Does that make sense at all? :) It was clear Thanks. At the moment when i try ls | ls it comes out crazy like mysh.1 , mysh .2 ....keeps going and ls |wc -c does not execute . Any suggestion will be appreciated. Cheers. From krante01@csse.uwa.edu.au Wed Oct 28 20:30:32 2015 Date: Wed Oct 28 20:30:32 2015 To: help2002@csse.uwa.edu.au Received: from 125.253.101.236 Subject: Step 9: mysh prints out extra prompts From: "Emma Krantz" <21500183@student.uwa.edu.au> X-smilie: none X-img: none If my shell script was as follows: cd ls echo meow > out.txt I get 3 extra empty "prompt" lines (like mysh.5\n), one for each command. Every time main() exits, it adds a new one. Is this an issue? From graven01@csse.uwa.edu.au Wed Oct 28 20:31:16 2015 Date: Wed Oct 28 20:31:16 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Step 9 From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > > > "Christopher McDonald" wrote: > > > > > "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > > > > > > > Can somebody please verify that this is the correct method for step 9, thankyou. :) > > > > > > I think you should re-read the project sheet: > > > > > > - a shellscript could exist in any of the directories in your PATH > > > - there's no specific filename extension required > > > - there's nothing stated about specifically looking for the shellscript in the current directory > > > - shellscript execution has nothing to do with CDPATH > > > > Oh, ok thanks for getting back to me, it seems I will have to make some changes then. Thanks, Ben. :) > > OK, I have spent the last couple of hours trying to understand what is going on in step 9, can somebody > please break step 9 down into steps, so I know what I actually have to do, because at the moment I'm > stumped, and the project is due in less than 48 hours :o yeah i'm a little stumped as well, i tried a few things (throwing shit at wall hoping to stick)! reassigning it as t->infile and calling the function recursively trying to execv a new child of ./mysh with < nameofscript kind of thing un-appended the "./" from t->argv[0] then fopen it, then while fgets each line redirected to stdin perhaps of a freshly forked ./mysh but cant quite (yet) figure out how to feed it a line at a time ( besides looking at a pipe perhaps ?) but i take 2 steps forward then 100 steps back, ive spent a long time going in circles throughout this project, hope i gave some ideas of what..(not) to do. Good luck if you have any ideas feel free to share :D From liaoj02@csse.uwa.edu.au Wed Oct 28 20:35:59 2015 Date: Wed Oct 28 20:35:59 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.126.138 Subject: Step 8 .. From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Now if I the ls |wc -c, I gives: mysh.2 wc: stdin: fstat: Bad file descriptor mysh.3 wc: stdin: fstat: Bad file descriptor mysh.4 wc: stdin: fstat: Bad file descriptor mysh.5 wc: stdin: fstat: Bad file descriptor ... LOL From krante01@csse.uwa.edu.au Wed Oct 28 20:36:51 2015 Date: Wed Oct 28 20:36:51 2015 To: help2002@csse.uwa.edu.au Received: from 125.253.101.236 Subject: Step 9: mysh prints out extra prompts From: "Emma Krantz" <21500183@student.uwa.edu.au> X-smilie: none X-img: none whoops, that should be step 9 and not step 10! [Fixed] From graven01@csse.uwa.edu.au Wed Oct 28 20:37:41 2015 Date: Wed Oct 28 20:37:41 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Step 8 .. From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none try swapping the 1 with the 0 and the 0 with the 1 From nelsoj07@csse.uwa.edu.au Wed Oct 28 22:06:13 2015 Date: Wed Oct 28 22:06:13 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: Step 9 From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none I think I've got the right idea for this, but bare with me if it's shockingly explained: PATH = /:/jake:/dev > testscript 1. So for each directory in PATH, check whether or not the asked for program is present, and if so try and execute it, assuming with execv() 2. /testscript doesn't execute with execv() 3. Check if there is a file in that directory with the correct name, and executable ( maybe check with access() ? ), if not go to step 1 with the next folder in PATH 4. If so then call the parser and try and get a new cmd_tree * from the file 6. Execute your new sparkly cmd_tree 7. ... 8. Profit Does that make it any clearer? :) From nelsoj07@csse.uwa.edu.au Wed Oct 28 22:12:20 2015 Date: Wed Oct 28 22:12:20 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: Step 7 - Error while opening file From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Does that call fail if the file already exists? Also do you need to set the permissions for the file created? http://codewiki.wikidot.com/c:system-calls:open From lis63@csse.uwa.edu.au Wed Oct 28 22:28:07 2015 Date: Wed Oct 28 22:28:07 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.221.171 Subject: Step 9 From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > I think I've got the right idea for this, but bare with me if it's shockingly explained: > > PATH = /:/jake:/dev > > > testscript > > 1. So for each directory in PATH, check whether or not the asked for program is present, and if so try and execute it, > assuming with execv() > 2. /testscript doesn't execute with execv() > 3. Check if there is a file in that directory with the correct name, and executable ( maybe check with access() ? ), if > not go to step 1 with the next folder in PATH > 4. If so then call the parser and try and get a new cmd_tree * from the file > 6. Execute your new sparkly cmd_tree > 7. ... > 8. Profit > > Does that make it any clearer? :) Great! I think you are right! Now, I have to re-write my function!!! From bokl01@csse.uwa.edu.au Wed Oct 28 23:02:43 2015 Date: Wed Oct 28 23:02:43 2015 To: help2002@csse.uwa.edu.au Received: from 134.7.114.118 Subject: Step 9: mysh prints out extra prompts From: "Louis Bok" <21506299@student.uwa.edu.au> X-smilie: none X-img: none "Emma Krantz" <21500183@student.uwa.edu.au> wrote: > If my shell script was as follows: > > cd > ls > echo meow > out.txt > > I get 3 extra empty "prompt" lines (like mysh.5\n), one for each command. Every time > main() exits, it adds a new one. Is this an issue? From bokl01@csse.uwa.edu.au Wed Oct 28 23:05:25 2015 Date: Wed Oct 28 23:05:25 2015 To: help2002@csse.uwa.edu.au Received: from 134.7.114.118 Subject: Step 9: mysh prints out extra prompts From: "Louis Bok" <21506299@student.uwa.edu.au> X-smilie: none X-img: none sorry accidentally pressed reply :P From liaoj02@csse.uwa.edu.au Wed Oct 28 23:16:19 2015 Date: Wed Oct 28 23:16:19 2015 To: help2002@csse.uwa.edu.au Received: from 180.233.126.138 Subject: Step 8 .. From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none NOPE From lis63@csse.uwa.edu.au Thu Oct 29 00:02:46 2015 Date: Thu Oct 29 00:02:46 2015 To: help2002@csse.uwa.edu.au Received: from 180.216.42.56 Subject: Step 9 From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > I think I've got the right idea for this, but bare with me if it's shockingly explained: > > PATH = /:/jake:/dev > > > testscript > > 1. So for each directory in PATH, check whether or not the asked for program is present, and if so try and execute it, > assuming with execv() > 2. /testscript doesn't execute with execv() > 3. Check if there is a file in that directory with the correct name, and executable ( maybe check with access() ? ), if > not go to step 1 with the next folder in PATH > 4. If so then call the parser and try and get a new cmd_tree * from the file > 6. Execute your new sparkly cmd_tree > 7. ... > 8. Profit > > Does that make it any clearer? :) Hi, now I think maybe we should go through each directory in PATH first until we find an executable file. If not, then we should go through each directory in PATH to find a shell script. For example if the PATH = /:/jake:/dev, and in /jake there is a shell script like testscript, and in /dev, there is a executable file also called testscript. I think we should execute the executable file rather the script. I will test it on Lab tomorrow as my standard shell cannot run a plain text file. From bullof01@csse.uwa.edu.au Thu Oct 29 00:18:45 2015 Date: Thu Oct 29 00:18:45 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.253.78 Subject: Step 8 .. From: "Fraser Bullock" <21299527@student.uwa.edu.au> X-smilie: none X-img: none look at mysh.c // READ AND EXECUTE COMMANDS FROM stdin UNTIL IT IS CLOSED (with control-D) while(!feof(stdin)) { CMDTREE *t = parse_cmdtree(stdin); your routing stdin into stdin, confusing. I got this when I closed something where it wasn't meant to be closed. From lis63@csse.uwa.edu.au Thu Oct 29 00:20:54 2015 Date: Thu Oct 29 00:20:54 2015 To: help2002@csse.uwa.edu.au Received: from 180.216.42.56 Subject: How to deal with "time (cal;ls)" From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > "Sunjue Li" <21777965@student.uwa.edu.au> wrote: > > > WOW! I need to rewrite many functions!! > > Surely not! > Unless you're not considering shellscripts to be almost identical to standard commands. > > Can you execute: time time date > time time time time time time date > ? After whole night work, it runs right now! Thank you. From lis63@csse.uwa.edu.au Thu Oct 29 00:28:06 2015 Date: Thu Oct 29 00:28:06 2015 To: help2002@csse.uwa.edu.au Received: from 180.216.42.56 Subject: Step 9: mysh prints out extra prompts From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none "Emma Krantz" <21500183@student.uwa.edu.au> wrote: > If my shell script was as follows: > > cd > ls > echo meow > out.txt > > I get 3 extra empty "prompt" lines (like mysh.5\n), one for each command. Every time > main() exits, it adds a new one. Is this an issue? The first prompt is caused by feof(), the second one may be caused by a blank new line in your script, and the last one is normal, I think. I get the number of lines of the script with fgets() first to avoid the first prompt. I don't like my solution, if you find a better solution, please tell me! Besides, I don't know how to avoid the other prompts, if you find any solution please tell me! From bullof01@csse.uwa.edu.au Thu Oct 29 01:12:44 2015 Date: Thu Oct 29 01:12:44 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.253.78 Subject: Submission Format From: "Fraser Bullock" <21299527@student.uwa.edu.au> X-smilie: heart.png X-img: none Just quickly asking. for ease, should the submission be done by placing all of the required .c .h files and the make file in a zip? or should we only submit the files we've changed/created and the marker will fill in the rest? and should we zip it and submit the one file to cssubmit or not zip it and upload several files? I know it shouldn't matter in the end, but I want to make it as easy as possible for my marker <3 thanks. From 00014979@csse.uwa.edu.au Thu Oct 29 05:10:46 2015 Date: Thu Oct 29 05:10:46 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: Step 9: mysh prints out extra prompts From: "Christopher McDonald" X-smilie: none X-img: none "Emma Krantz" <21500183@student.uwa.edu.au> wrote: > I get 3 extra empty "prompt" lines (like mysh.5\n), one for each command. Every time > main() exits, it adds a new one. Is this an issue? The prompt is printed from a function inside parser.c If you set the global Boolean variable interactive to false the prompt won't be printed. From 00014979@csse.uwa.edu.au Thu Oct 29 05:12:55 2015 Date: Thu Oct 29 05:12:55 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: Submission Format From: "Christopher McDonald" X-smilie: none X-img: none Submit all of your files, including any unmodified starting ones. Either submit them as individual files or in a single zip archive. From 00014979@csse.uwa.edu.au Thu Oct 29 05:14:44 2015 Date: Thu Oct 29 05:14:44 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: Some final clarifications From: "Christopher McDonald" X-smilie: none X-img: none "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> wrote: > Pretty much finished, just have a few clarifications: > 1. Are we supposed to submit every file individually, or can we just submit a .zip? Either way. > 2. With stuff like 'time', we just print "execution time: xxx microseconds". Is this > acceptable, or is there a specific format required? As on the project sheet: 24msec > 3. Since we reap background processes when they're finished, we print out something > like "reaped process id xxx" when a process is reaped. Should we get rid of this > (i.e. will it confuse the auto marker), or can we just keep it in (since we thought > it was good that we got a signal handler working for background processes, and > didn't want to scrap it just cause it wasn't a requirement) Leave the extra code in. There won't be an automarker; too difficult. From nelsoj07@csse.uwa.edu.au Thu Oct 29 08:26:33 2015 Date: Thu Oct 29 08:26:33 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: Step 9: mysh prints out extra prompts From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Thanks Chris! Makes sense :) From nelsoj07@csse.uwa.edu.au Thu Oct 29 08:33:46 2015 Date: Thu Oct 29 08:33:46 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: Step 9 From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none For a file to be executed by bash the permissions need to be set to execute. Try using this to test: Make a file testscript containing just the below, with no extension echo TESTING SCRIPT date ls Move the file to a directory in your PATH, and then try and run the below in your bash shell testscript It should fail, and say access denied ( or something similar, I can't remember). cd to the directory you placed it in and use the command below to set the permissions to executable. chmod 755 testscript Now try run it in your bash shell, and it should work. That is the expected behaviour for our handling of scripts I believe as well. So the only difference ( I believe ) between a regular program and a shellscript is that the shell tries to run it with execv first, which will fail, and then try and read it in as a script, as if what is in the file is the stdin of the shell. Does that help clear it up Li? :) From lis63@csse.uwa.edu.au Thu Oct 29 09:41:36 2015 Date: Thu Oct 29 09:41:36 2015 Edit: Thu Oct 29 10:04:21 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.116.219 Subject: Step 9 From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > For a file to be executed by bash the permissions need to be set to execute. Try using this to test: > > Make a file testscript containing just the below, with no extension > > echo TESTING SCRIPT > date > ls > > Move the file to a directory in your PATH, and then try and run the below in your bash shell > > testscript > > It should fail, and say access denied ( or something similar, I can't remember). cd to the directory you placed it in and use the > command below to set the permissions to executable. > > chmod 755 testscript > > Now try run it in your bash shell, and it should work. > > That is the expected behaviour for our handling of scripts I believe as well. So the only difference ( I believe ) between a regular > program and a shellscript is that the shell tries to run it with execv first, which will fail, and then try and read it in as a script, > as if what is in the file is the stdin of the shell. > > Does that help clear it up Li? :) I see. Thank you You are right. I test it again. To avoid misguiding, I delete my former comments From nelsoj07@csse.uwa.edu.au Thu Oct 29 09:46:57 2015 Date: Thu Oct 29 09:46:57 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: Step 9 From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none A file needs to be have executable permissions to be run as a script in bash regardless, so the textfile that is not marked as executable will never be run. Apart from that, yep the first one found will be executed :) From lis63@csse.uwa.edu.au Thu Oct 29 10:14:26 2015 Date: Thu Oct 29 10:14:26 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.116.219 Subject: Step 9: mysh prints out extra prompts From: "Sunjue Li" <21777965@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > "Emma Krantz" <21500183@student.uwa.edu.au> wrote: > > > I get 3 extra empty "prompt" lines (like mysh.5\n), one for each command. Every time > > main() exits, it adds a new one. Is this an issue? > > The prompt is printed from a function inside parser.c > > If you set the global Boolean variable interactive > to false the prompt won't be printed. Thank you!! Help me a lot! From hon06@csse.uwa.edu.au Thu Oct 29 12:18:26 2015 Date: Thu Oct 29 12:18:26 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.130 Subject: Step 9 From: "Nathan Ho" <21506898@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > Just a quick and dirty theory on why the last line is ignored ( unless there is a newline > character there? ), but is it because that would have the same effect as you typing into the > prompt for ./mysh and then not hitting enter but closing the window, causing it not to run > without that newline character? > Just wondering, has anyone managed to solve this issue? Any advice would be appreciated. From nelsoj07@csse.uwa.edu.au Thu Oct 29 13:07:03 2015 Date: Thu Oct 29 13:07:03 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: Step 9 From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Yep, Chris did: The prompt is printed from a function inside parser.c If you set the global Boolean variable interactive to false the prompt won't be printed. Helped me out! :) From hon06@csse.uwa.edu.au Thu Oct 29 13:08:14 2015 Date: Thu Oct 29 13:08:14 2015 Edit: Thu Oct 29 13:08:39 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.130 Subject: Step 9 From: "Nathan Ho" <21506898@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > Yep, Chris did: > > The prompt is printed from a function inside parser.c > > If you set the global Boolean variable interactive > to false the prompt won't be printed. > > Helped me out! :) Sorry, is this to do with the last line of a shellscript file not being read? From 00014979@csse.uwa.edu.au Thu Oct 29 13:12:59 2015 Date: Thu Oct 29 13:12:59 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Step 9 From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Sorry, is this to do with the last line of a shellscript file not being read? Does your last line actually have a newline character at its end? From nelsoj07@csse.uwa.edu.au Thu Oct 29 13:13:33 2015 Date: Thu Oct 29 13:13:33 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: Step 9 From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Oh sorry, misunderstood your question! I'd say it's because the parser ( I think ) interprets the new line character as the trigger to read the line into a cmd_tree. Potentially you could put a new line character at the end of the file? Going to try now and will get back to you :) From hon06@csse.uwa.edu.au Thu Oct 29 13:13:42 2015 Date: Thu Oct 29 13:13:42 2015 Edit: Thu Oct 29 13:14:17 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.130 Subject: Step 9 From: "Nathan Ho" <21506898@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > Sorry, is this to do with the last line of a shellscript file not being read? > > Does your last line actually have a newline character at its end? No (as in their is no newline at the end of the shellscript), but when I tested in real bash shell it didn't matter. It would process the commands even if the file doesn't have a newline at the end. From 00014979@csse.uwa.edu.au Thu Oct 29 13:21:30 2015 Date: Thu Oct 29 13:21:30 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Step 9 From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > No (as in their is no newline at the end of the shellscript), but when I tested in > real bash shell it didn't matter. It would process the > commands even if the file doesn't have a newline at the end. To quickly achieve the outcome you want, I suggest placing a newline at the end of your file. From coopea04@csse.uwa.edu.au Thu Oct 29 15:04:25 2015 Date: Thu Oct 29 15:04:25 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.121 Subject: Return value of a forked function From: "Adrian Cooper" <20786307@student.uwa.edu.au> X-smilie: none X-img: none If I call a function to get its return value, and the function forks, is there any way to choose which it accepts, the parent's or child's? From hollih01@csse.uwa.edu.au Thu Oct 29 15:11:49 2015 Date: Thu Oct 29 15:11:49 2015 To: help2002@csse.uwa.edu.au Received: from 110.175.129.147 Subject: Step 8 confusion From: "Henry Hollingworth" <21471423@student.uwa.edu.au> X-smilie: none X-img: none Just thought I'd drop a comment here. I was doing 8) and came up with a solution very similar to what Jake outlines however I was getting some 'bad file descriptor' errors on *some* combinations of commands. I fixed this by CLOSING the in/out file descriptors for the pipe once they had served their purpose. I.e: int fd[2]; pipe(fd); // run left tree close(fd[1]); // run right tree close(fd[0]); Was driving me mad for a while... Hope this helps anyone with a similar issue. From 00014979@csse.uwa.edu.au Thu Oct 29 15:15:53 2015 Date: Thu Oct 29 15:15:53 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Return value of a forked function From: "Christopher McDonald" X-smilie: none X-img: none "Adrian Cooper" <20786307@student.uwa.edu.au> wrote: > If I call a function to get its return value, and the function forks, is there any way to > choose which it accepts, the parent's or child's? Unusual. You could pass a Boolean parameter to the function, but (unless you use a file to shore/provide some information) the only thing that you can pass back from the child to the parent is the child's exit status. But it's unclear what you're attempting. From coopea04@csse.uwa.edu.au Thu Oct 29 15:20:33 2015 Date: Thu Oct 29 15:20:33 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.121 Subject: Return value of a forked function From: "Adrian Cooper" <20786307@student.uwa.edu.au> X-smilie: none X-img: none After forking to make a subshell, I want to return the exit value of the subshell to the function that called it From 00014979@csse.uwa.edu.au Thu Oct 29 15:24:24 2015 Date: Thu Oct 29 15:24:24 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Return value of a forked function From: "Christopher McDonald" X-smilie: none X-img: none "Adrian Cooper" <20786307@student.uwa.edu.au> wrote: > After forking to make a subshell, I want to return the exit value of the subshell to the function that called it So there will be (need to be) the parent process waiting for the child (the subshell) to terminate, to gather the child's exit status, and to return it. It seems that you're overthinking it. From liaoj02@csse.uwa.edu.au Thu Oct 29 15:26:45 2015 Date: Thu Oct 29 15:26:45 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.84.234 Subject: setenv() From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > im am trying to use the setenv() function to set the new enviromental variable > here is a test case > ---------------------------------------------------------------------------- > #include "mysh.h" > #include > #include > > int main(int argc, char *argv[]){ > char *p="GOOD ONE"; > setenv("PATH",p,0); > > printf("%s\n",PATH); > } > ------------------------------------------------------------------------------ > howevver i am recieving the error iplicit delaration of function setenv() > even though we i use man setenv the function is included in the header DO we have to check the validity of the input arguments? But I think I can only check if the pathname is null, but cannot really know if they are valid. Anyway, when the user try to do things like ls, if the PATH is not set properly, it won't execute it . I think thats the job of the functions in do_ls() to report user that their PATH may not be valid.. From 00014979@csse.uwa.edu.au Thu Oct 29 15:29:14 2015 Date: Thu Oct 29 15:29:14 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: setenv() From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Anyway, when the user try to do things like ls, if the PATH is not set properly, it won't > execute it . I think thats the job of the functions in do_ls() to report user that their > PATH may not be valid.. If a user sets their PATH to an unusable or stupid value, well, bad luck for them. They'll just need to (re)set it to something useful later. I've *very* worried by your suggestion that you have a do_ls() function??? From newmal01@csse.uwa.edu.au Thu Oct 29 16:03:23 2015 Date: Thu Oct 29 16:03:23 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: marking key From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none Hey i was just wondering could we have a copy of the markng key used for this project like the one we recieved in the feedback of the 1st project? also i undrstand it is highly unlikely we will reieve our results before the exam, but will we recieve them afterwards? From defrav01@csse.uwa.edu.au Thu Oct 29 16:05:02 2015 Date: Thu Oct 29 16:05:02 2015 To: help2002@csse.uwa.edu.au Received: from 125.253.34.37 Subject: step 7 From: "Vincent De Francesco" <21501733@student.uwa.edu.au> X-smilie: heartbroken.png X-img: none how do you do it? From newmal01@csse.uwa.edu.au Thu Oct 29 16:06:47 2015 Date: Thu Oct 29 16:06:47 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: fork() function From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none i current have a finished working shell (bit dodgey though) i was wondering if it was porssible to have a function which forks a new process and continues in the child process outside of the function? From nelsoj07@csse.uwa.edu.au Thu Oct 29 17:22:04 2015 Date: Thu Oct 29 17:22:04 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.52.216 Subject: fork() function From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none What do you mean by continues in the child process outside of the function? If you were to call say execvp(bash) then if the execvp is successful your process is replaced by bash. This would effectively keep a child process running outside of a function and that's just one example off the top of my head :) From nelsoj07@csse.uwa.edu.au Thu Oct 29 17:23:39 2015 Date: Thu Oct 29 17:23:39 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.52.216 Subject: step 7 From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none http://linux.die.net/man/3/printf fprintf() in particular :) From hollih01@csse.uwa.edu.au Thu Oct 29 17:27:11 2015 Date: Thu Oct 29 17:27:11 2015 To: help2002@csse.uwa.edu.au Received: from 110.175.129.147 Subject: Step 9 From: "Henry Hollingworth" <21471423@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > I think I've got the right idea for this, but bare with me if it's shockingly explained: > > PATH = /:/jake:/dev > > > testscript > > 1. So for each directory in PATH, check whether or not the asked for program is present, and if so try and execute it, > assuming with execv() > 2. /testscript doesn't execute with execv() > 3. Check if there is a file in that directory with the correct name, and executable ( maybe check with access() ? ), if > not go to step 1 with the next folder in PATH > 4. If so then call the parser and try and get a new cmd_tree * from the file > 6. Execute your new sparkly cmd_tree > 7. ... > 8. Profit > > Does that make it any clearer? :) I think the specification is pretty clear in that to achieve the running of the file you must *should* spawn a new mysh process and have it's stdin point to the file itself. I have this method working, but before was doing it as you suggested above. My process essentially boils down to: dup2(shellscript_fd, STDIN_FILENO); execv("mysh", {"mysh", ..., NULL}); From 00014979@csse.uwa.edu.au Thu Oct 29 17:38:36 2015 Date: Thu Oct 29 17:38:36 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: marking key From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hey i was just wondering could we have a copy of the markng key used for this project > like the one we recieved in the feedback of the 1st project? Yes, the feedback sheet will be similar, and returned when the 2nd project's marked. > also i undrstand it is highly unlikely we will reieve our results before the exam, but > will we recieve them afterwards? Yes, all marks will be returned, and a period to comment on or modify them. From lyz01@csse.uwa.edu.au Thu Oct 29 17:46:02 2015 Date: Thu Oct 29 17:46:02 2015 To: help2002@csse.uwa.edu.au Received: from 110.141.146.39 Subject: Step 9 From: "Zen Ly" <21491901@student.uwa.edu.au> X-smilie: none X-img: none I tried something similar, but the issues I ran into were: What if the executable wasn't called mysh? What if the executable wasn't on the path / current working directory? Sure I guess you could use argv[0] from main, but that's not guaranteed to be a path to the executable. I tried making a function to get the path to the executable, but it seems that it's very platform dependent, so I doubt that this is the solution. But yeah, otherwise it's really just running "mysh < script.sh", is how I interpreted question 9 as well. From 00014979@csse.uwa.edu.au Thu Oct 29 17:49:32 2015 Date: Thu Oct 29 17:49:32 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: Step 9 From: "Christopher McDonald" X-smilie: none X-img: none "Zen Ly" <21491901@student.uwa.edu.au> wrote: > But yeah, otherwise it's really just running "mysh < script.sh", is how I interpreted question 9 as well. If only there was an instance of mysh already running somewhere, which you could make read the shellscript's contents...... From abusha02@csse.uwa.edu.au Thu Oct 29 19:13:38 2015 Date: Thu Oct 29 19:13:38 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.191.235 Subject: Parser not a one-to-one math with normal shells From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none Hi Chris. After some testing and freaking out (because my output for some complex sequences of commands wasn't matching the normal bash output), it seems as though the parser is the heart of these errors I've been encountering. One example is the command sequence: cal && ls || pwd && cal 2015 || cal 2014 In a normal bash, this seems to run 'cal', followed by 'ls', followed by 'cal 2015.' In my shell, it runs 'cal', followed by 'ls', so I got a little worried for a time. It seems, though, that my output is exactly what should be expected. Having passed this sequence to the online cmdtree visualizer (which has been very helpful!), my output is quite expected. I have attached the command tree generated by this sequence, so you can see it below (I hope). Looking at that tree, my shell seems to function as expected. The first 'cal' runs successfully, so it moves on to the left hand side of the first 'or', which is 'ls', and runs it. Since 'ls' returns successfully, it ignores the right hand side of the 'or', which amounts to the rest of the command sequence. Given the output from the normal bash, however, I can assume their command tree is quite different. I believe they start splitting from the right, with some sort of precedence order. For example, I think their command shell would probably look like: AND or or and cal ls pwd cal 2015 cal 2014 Thus, in bash, it would run cal, then ls (if cal returns success), then ignore pwd, since cal && ls returned success. It would then run cal 2015, since the preceding sequence ran successfully, and then ignore cal 2014, since cal 2015 returned success. Thus, unlike our shells, which effectively run cal then ls, bash would run cal, then ls, and then cal 2015. So to get to the meat of my question: can we assume the parser does not function in the same way that bash's parser does? Does this not also make bash a rather unreliable method of testing our own shells, since it parses commands differently? If the answer to these questions are both yes, I would probably advise students not to use bash as a definitive testing tool, because they're going to try hunting down nonexistent errors (though it's probably quite late to bring this up). From hollih01@csse.uwa.edu.au Thu Oct 29 19:13:54 2015 Date: Thu Oct 29 19:13:54 2015 To: help2002@csse.uwa.edu.au Received: from 110.175.129.147 Subject: Step 9 From: "Henry Hollingworth" <21471423@student.uwa.edu.au> X-smilie: none X-img: none "Zen Ly" <21491901@student.uwa.edu.au> wrote: > I tried something similar, but the issues I ran into were: > What if the executable wasn't called mysh? > What if the executable wasn't on the path / current working directory? > > Sure I guess you could use argv[0] from main, but that's not guaranteed to be a path to the executable. > > I tried making a function to get the path to the executable, but it seems that it's very platform dependent, so I doubt that this is the > solution. > > But yeah, otherwise it's really just running "mysh < script.sh", is how I interpreted question 9 as well. Zen I think you may have gotten a few things confused. The 'mysh' executable or result of building your project can indeed have any name you like, however you can define this at build time, and won't change (well, you could change the filename... but that would be the same as renaming the 'cd' executable on your machine...): gcc -o mysh ... or gcc -o ichoosethisname ... This is a seperate from the shell script executable - this can have any name and be located anywhere. This shell script executable is just a text file with the executable flag set. The lines in this file represent actual commands you could provide to 'mysh' (our project program). ~~~~~~~~~~~~~ My use of: execv("mysh", ...) Is done not to invoke 'any' shell script but *specifically* our project program. The 'mysh' program will end up reading from the shell script if you correctly configure the stdin of 'mysh', this is achieved via the dup2() call. From 00014979@csse.uwa.edu.au Thu Oct 29 19:41:49 2015 Date: Thu Oct 29 19:41:49 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: Parser not a one-to-one math with normal shells From: "Christopher McDonald" X-smilie: none X-img: none "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> wrote: > Hi Chris. After some testing and freaking out (because my output for some complex > sequences of commands wasn't matching the normal bash output), it seems as though > the parser is the heart of these errors I've been encountering. One example is the > command sequence: > > cal && ls || pwd && cal 2015 || cal 2014 Very interesting observation! "Fortunately" you're trying examples that are waaaaaaay more complicated that those that we'll have time to test during the marking, so hopefully testing against bash won't concern too many students. In fact, as all the programs in your example are successful (if run), let's reduce it to: echo a && echo b || echo c && echo d || echo e Now, bash, zsh, and ksh produce: a b d while csh, tcsh, and (my sample) mysh produce: a b Certainly, not all shells are equal, which is very surprising! From devilf01@csse.uwa.edu.au Thu Oct 29 19:42:40 2015 Date: Thu Oct 29 19:42:40 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.157.136 Subject: Step 7. stdin redirect, what calls to test with other than sort? From: "Friedel de Villiers" <10308548@student.uwa.edu.au> X-smilie: none X-img: c08ad53f7842bcf6c6f54355f178d35d.png Hi guys, Does anyone know of any calls other than sort i can test step 7.1 with? I get it to read the .txt file i made, but the output looks suspect. Its all in alphabetical order, but lots of extra characters to. So i would like to test it with something else. Any advise appreciated. From 00014979@csse.uwa.edu.au Thu Oct 29 19:48:40 2015 Date: Thu Oct 29 19:48:40 2015 Edit: Thu Oct 29 19:57:47 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: Step 7. stdin redirect, what calls to test with other than sort? From: "Christopher McDonald" X-smilie: none X-img: none Choose a text file with a more 'obvious' outcome: sort < globals.c or wc -l < globals.c From devilf01@csse.uwa.edu.au Thu Oct 29 20:32:54 2015 Date: Thu Oct 29 20:32:54 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.157.136 Subject: Step 7. stdin redirect, what calls to test with other than sort? From: "Friedel de Villiers" <10308548@student.uwa.edu.au> X-smilie: none X-img: none Thanks for getting back to me, that worked. Or should i say, worked the second time, as i accidentally wrote sort > globals.c the first time and wiped my globals.c file... From hollih01@csse.uwa.edu.au Thu Oct 29 20:49:54 2015 Date: Thu Oct 29 20:49:54 2015 To: help2002@csse.uwa.edu.au Received: from 110.175.129.147 Subject: Return value of a forked function From: "Henry Hollingworth" <21471423@student.uwa.edu.au> X-smilie: none X-img: none "Adrian Cooper" <20786307@student.uwa.edu.au> wrote: > After forking to make a subshell, I want to return the exit value of the subshell to the function that called it Ensure you store the pid of the child process (the return value of fork()). In the code the parent will execute use waitpid() to wait for the process to stop and get it's return value. BE CAREFUL THOUGH! In the child going exit(XXX) where X is negative and/or large can result in undefined behaviour, so I recommend exiting only with exit(EXIT_SUCCESS) or exit(EXIT_FAILURE). pid_t pid = fork() if () { int status; waitpid(pid, &status, 0); } From liaoj02@csse.uwa.edu.au Thu Oct 29 21:10:29 2015 Date: Thu Oct 29 21:10:29 2015 Edit: Thu Oct 29 21:11:14 2015 To: help2002@csse.uwa.edu.au Received: from 43.252.114.244 Subject: setenv() From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Nah.just an easier way to describe that sort of internal command that does not have '/'.. Not the real naming in my project.. From abusha02@csse.uwa.edu.au Thu Oct 29 21:29:56 2015 Date: Thu Oct 29 21:29:56 2015 Edit: Thu Oct 29 21:30:31 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.101.110 Subject: Parser not a one-to-one math with normal shells From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none Whoops! I was just trying to correct a typo, but posted a reply instead. My bad From lyz01@csse.uwa.edu.au Thu Oct 29 21:53:34 2015 Date: Thu Oct 29 21:53:34 2015 Edit: Thu Oct 29 21:59:00 2015 To: help2002@csse.uwa.edu.au Received: from 110.141.146.39 Subject: Step 9 From: "Zen Ly" <21491901@student.uwa.edu.au> X-smilie: none X-img: none "Henry Hollingworth" <21471423@student.uwa.edu.au> wrote: > "Zen Ly" <21491901@student.uwa.edu.au> wrote: > > > I tried something similar, but the issues I ran into were: > > What if the executable wasn't called mysh? > > What if the executable wasn't on the path / current working directory? > > > > Sure I guess you could use argv[0] from main, but that's not guaranteed to be a path to the executable. > > > > I tried making a function to get the path to the executable, but it seems that it's very platform dependent, so I doubt that this is the > > solution. > > > > But yeah, otherwise it's really just running "mysh < script.sh", is how I interpreted question 9 as well. > > Zen I think you may have gotten a few things confused. The 'mysh' executable or result of building your project can indeed have any name you like, > however you can define this at build time, and won't change (well, you could change the filename... but that would be the same as renaming the 'cd' > executable on your machine...): > > gcc -o mysh ... > or > gcc -o ichoosethisname ... > > This is a seperate from the shell script executable - this can have any name and be located anywhere. This shell script executable is just a text file > with the executable flag set. The lines in this file represent actual commands you could provide to 'mysh' (our project program). > > ~~~~~~~~~~~~~ > > My use of: > > execv("mysh", ...) > > > Is done not to invoke 'any' shell script but *specifically* our project program. The 'mysh' program will end up reading from the shell script if you > correctly configure the stdin of 'mysh', this is achieved via the dup2() call. I am not mistaken. Did you read my whole post? I'm talking about question 9, and so are you. You assumed that "mysh" the program we're writing exists on the PATH. For example, go a a folder that does not contain mysh, and don't have mysh on the path, then try running a script from there. I discussed methods for getting the path to mysh (the program that we're making) and how it's very platform dependent. Main point: You can't depend on mysh being compiled as "mysh", nor can you depend on mysh being on the PATH, you have hardcoded "mysh" to run, but it makes a lot of assumptions that it shouldn't. Besides, Chris hinted at the intended way to do it. From hollih01@csse.uwa.edu.au Thu Oct 29 22:24:57 2015 Date: Thu Oct 29 22:24:57 2015 To: help2002@csse.uwa.edu.au Received: from 110.175.129.147 Subject: Step 9 From: "Henry Hollingworth" <21471423@student.uwa.edu.au> X-smilie: none X-img: none "Zen Ly" <21491901@student.uwa.edu.au> wrote: > "Henry Hollingworth" <21471423@student.uwa.edu.au> wrote: > > > "Zen Ly" <21491901@student.uwa.edu.au> wrote: > > > > > I tried something similar, but the issues I ran into were: > > > What if the executable wasn't called mysh? > > > What if the executable wasn't on the path / current working directory? > > > > > > Sure I guess you could use argv[0] from main, but that's not guaranteed to be a path to the executable. > > > > > > I tried making a function to get the path to the executable, but it seems that it's very platform dependent, so I doubt that this is the > > > solution. > > > > > > But yeah, otherwise it's really just running "mysh < script.sh", is how I interpreted question 9 as well. > > > > Zen I think you may have gotten a few things confused. The 'mysh' executable or result of building your project can indeed have any name you like, > > however you can define this at build time, and won't change (well, you could change the filename... but that would be the same as renaming the 'cd' > > executable on your machine...): > > > > gcc -o mysh ... > > or > > gcc -o ichoosethisname ... > > > > This is a seperate from the shell script executable - this can have any name and be located anywhere. This shell script executable is just a text file > > with the executable flag set. The lines in this file represent actual commands you could provide to 'mysh' (our project program). > > > > ~~~~~~~~~~~~~ > > > > My use of: > > > > execv("mysh", ...) > > > > > > Is done not to invoke 'any' shell script but *specifically* our project program. The 'mysh' program will end up reading from the shell script if you > > correctly configure the stdin of 'mysh', this is achieved via the dup2() call. > > I am not mistaken. Did you read my whole post? I'm talking about question 9, and so are you. > You assumed that "mysh" the program we're writing exists on the PATH. > For example, go a a folder that does not contain mysh, and don't have mysh on the path, then try running a script from there. > > I discussed methods for getting the path to mysh (the program that we're making) and how it's very platform dependent. > > Main point: You can't depend on mysh being compiled as "mysh", nor can you depend on mysh being on the PATH, you have hardcoded "mysh" to run, but it makes a > lot of assumptions that it shouldn't. > > Besides, Chris hinted at the intended way to do it. Ahh I see what you mean, sorry! Chris's previous post seems to contradict the specification which says "In this case you should execute another copy of mysh to read its input from the shell script.". If you use the same process to evaluate the file you aren't making another copy of mysh... But yes like you say, locating mysh can be difficult... From ahmedm07@csse.uwa.edu.au Thu Oct 29 23:05:12 2015 Date: Thu Oct 29 23:05:12 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.56.82 Subject: Step 8 - Piping From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none Hey, So i have been working on piping for a bit now. I have never been more confused in my life at this specific moment. So. Obviously there is something wrong with my execute_pipe(CMDTREE *pipe) function. However, i cannot for the life of me figure out what it is. The error occurs somewhat like this: First, i run the command which i am using for testing is this : cat mysh.h | wc which gives me no output and jumps straight to the next prompt. Afterwards, i normally ^C out of my shell and then upon pressing any key possible, this happens : mysh.496 cat mysh.h | wc mysh.497 cat mysh.h | wc mysh.498 cat mysh.h | wc mysh.499 cat mysh.h | wc mysh.500 cat mysh.h | wc mysh.501 cat mysh.h | wc mysh.502 cat mysh.h | wc mysh.503 cat mysh.h | wc mysh.504 cat mysh.h | wc mysh.505 cat mysh.h | wc which repeats on forever. I am so confused as to what is happening. I have done a stand-alone file with just that function where i am able to run a command and upon testing the stand-alone file. Everything is all well and good. Would love to hear someone's thoughts on this? After a whole day's work, my brain isnt really at full-capacity anymore so it might just be something glaringly simple. Regards, MA From 00014979@csse.uwa.edu.au Fri Oct 30 05:05:21 2015 Date: Fri Oct 30 05:05:21 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: Step 9 From: "Christopher McDonald" X-smilie: none X-img: none "Henry Hollingworth" <21471423@student.uwa.edu.au> wrote: > Ahh I see what you mean, sorry! Chris's previous post seems to contradict the specification which says "In this case you should execute another copy of mysh to read its input > from the shell script.". If you use the same process to evaluate the file you aren't making another copy of mysh... But yes like you say, locating mysh can be difficult... No, there's no contradiction; why do you think it is/should be the *same* process, and not another? From 00014979@csse.uwa.edu.au Fri Oct 30 05:26:51 2015 Date: Fri Oct 30 05:26:51 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: Step 8 - Piping From: "Christopher McDonald" X-smilie: none X-img: none "Maktoom Ahmed" <21728592@student.uwa.edu.au> wrote: > The error occurs somewhat like this: > First, i run the command which i am using for testing is this : cat mysh.h | wc > which gives me no output and jumps straight to the next prompt. When forking new processes, the parent and child process each get a copy of any open file (or pipe) descriptors. Either process can independently manipulate their descriptors, and should close() the ones they don't require. ?? From nelsoj07@csse.uwa.edu.au Fri Oct 30 06:53:25 2015 Date: Fri Oct 30 06:53:25 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.146.141 Subject: setenv() From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none When you say internal command, have you written a function to list the files in the folder, or do you look for and run the ls program in the directories in PATH? From ahmedm07@csse.uwa.edu.au Fri Oct 30 07:22:29 2015 Date: Fri Oct 30 07:22:29 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.56.82 Subject: Step 8 - Piping From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none Ok? Sorry. I know that. Both processes are the same and should therefore will get the same descriptors. I am not really sure why you are telling me that however. From nelsoj07@csse.uwa.edu.au Fri Oct 30 07:43:45 2015 Date: Fri Oct 30 07:43:45 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.146.141 Subject: Step 8 - Piping From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Hey Maktoom, I think the key take away for your problem is the part here: Either process can independently manipulate their descriptors, and should close() the ones they don't require. Are you sure your closing the unneeded file descriptor? :) From liaoj02@csse.uwa.edu.au Fri Oct 30 07:46:26 2015 Date: Fri Oct 30 07:46:26 2015 To: help2002@csse.uwa.edu.au Received: from 43.252.114.95 Subject: setenv() From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > When you say internal command, have you written a function to list the files in the folder, or do you look for > and run the ls program in the directories in PATH? Is an automatic function like execvp From liaoj02@csse.uwa.edu.au Fri Oct 30 07:50:39 2015 Date: Fri Oct 30 07:50:39 2015 To: help2002@csse.uwa.edu.au Received: from 43.252.114.95 Subject: Exit() if process fails? From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Hello. I am a bit confused whether I should exit() for each execution. for example, in standard shell, cal && k ; ls will prints cal and ls , even though k fails. if I put exit() for N_AND type when t->right fails, then it won't do that. IN N_AND type I keeps running and exit() for t->right ignoring t->left's success or failure. Thanks From nelsoj07@csse.uwa.edu.au Fri Oct 30 07:57:02 2015 Date: Fri Oct 30 07:57:02 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.146.141 Subject: Exit() if process fails? From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Could you run execute_cmdtree(t->left) and save the resulting int, and then if int saved == 0 then run execute_cmdtree(t->right) ? Else you'd just continue to the next node. From ahmedm07@csse.uwa.edu.au Fri Oct 30 07:58:43 2015 Date: Fri Oct 30 07:58:43 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.56.82 Subject: Step 8 - Piping From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none Yup. I close the read side of the pipe when writing and vice versa. From liaoj02@csse.uwa.edu.au Fri Oct 30 08:09:07 2015 Date: Fri Oct 30 08:09:07 2015 Edit: Fri Oct 30 08:11:49 2015 To: help2002@csse.uwa.edu.au Received: from 43.252.114.95 Subject: Exit() if process fails? From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none Thats what I do. But ; is sort of like it has the highest priority so I just didn't put exit() for AND_TYPE or OR_TYPE. I just record the status for those case. didn't exit them. I think I did them twice. Just need to do it in execute_cmdtree() rather than a sub function calling a type.. From liaoj02@csse.uwa.edu.au Fri Oct 30 08:09:40 2015 Date: Fri Oct 30 08:09:40 2015 To: help2002@csse.uwa.edu.au Received: from 43.252.114.95 Subject: Step 8 - Piping From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none fork() twice. do CMD2 in child 2 From ahmedm07@csse.uwa.edu.au Fri Oct 30 08:17:52 2015 Date: Fri Oct 30 08:17:52 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.56.82 Subject: Step 8 - Piping From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none yup. i created two children. This is basically what i did : Created a pipe. Forked two new processes. Made it so that the write half of the pipe is same as stdout of the first process and the read of half is same as stdin of the second process using dup. Executed both sides of the command tree in each different process. I am not sure but i dont think i am allowed to post my code here, otherwise this would be much easier. The whole thing is driving me insane. The error isn't very helpful either so quite a pain really. From coopea04@csse.uwa.edu.au Fri Oct 30 09:39:18 2015 Date: Fri Oct 30 09:39:18 2015 Edit: Fri Oct 30 09:42:44 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.122 Subject: Which command is run in the background? From: "Adrian Cooper" <20786307@student.uwa.edu.au> X-smilie: none X-img: none Is it the command to the left or the right of the & symbol? And to clarify, the background command has to be run in the child fork of the asynchronous fork function, right? And does 'The exit value of background execution is success unless the fork call fails, in which case the exit value should indicate failure.' mean that it returns success or failure irrespective of the success or failure of the individual commands to the left or right, it only depends on the success of the forking? From 00014979@csse.uwa.edu.au Fri Oct 30 09:59:53 2015 Date: Fri Oct 30 09:59:53 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Which command is run in the background? From: "Christopher McDonald" X-smilie: none X-img: none "Adrian Cooper" <20786307@student.uwa.edu.au> wrote: > Is it the command to the left or the right of the & symbol? And to clarify, the background > command has to be run in the child fork of the asynchronous fork function, right? You can find the answer to this by comparing the execution of: ls & sleep 10 and sleep 10 & ls (and if it was just ls & it's obvious whether it's left or right) It's *usual* for the child branch to perform the background execution (though it could be either). > success or failure of the individual commands to the left or right, it only depends on the success of > the forking? You only have the success of the forking to work with, as you don't know/care about how the execution of the 3-day background process is doing. From coopea04@csse.uwa.edu.au Fri Oct 30 10:06:03 2015 Date: Fri Oct 30 10:06:03 2015 Edit: Fri Oct 30 10:08:36 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.122 Subject: Which command is run in the background? From: "Adrian Cooper" <20786307@student.uwa.edu.au> X-smilie: none X-img: none > You can find the answer to this by comparing the execution of: > > ls & sleep 10 > and > sleep 10 & ls This would work if my partner were clear on which side -should be- coded to run in the background. At the moment the command to the right is coded to run in the background. Also, is it ever valid to have & not be followed by anything else? > You only have the success of the forking to work with, as you don't know/care about how the execution of the 3-day > background process is doing. Well, we also have the execution of the non-background process, and seeing as & seems to take priority even over ; it seems logical that it might use the non-background process' execution From 00014979@csse.uwa.edu.au Fri Oct 30 10:08:49 2015 Date: Fri Oct 30 10:08:49 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Which command is run in the background? From: "Christopher McDonald" X-smilie: none X-img: none "Adrian Cooper" <20786307@student.uwa.edu.au> wrote: > This would work if my partner were clear on which side -should be- coded to run in the background. At the moment the command to > the right is coded to run in the background. Try the sleep example given; it's clear. > Also, is it ever valid to have & not be followed by anything else? Yes, it's the most frequently used form. From coopea04@csse.uwa.edu.au Fri Oct 30 11:23:09 2015 Date: Fri Oct 30 11:23:09 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.122 Subject: Late submission penalties? From: "Adrian Cooper" <20786307@student.uwa.edu.au> X-smilie: none X-img: none What are the late submission penalties? From 00014979@csse.uwa.edu.au Fri Oct 30 11:24:31 2015 Date: Fri Oct 30 11:24:31 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Late submission penalties? From: "Christopher McDonald" X-smilie: none X-img: none Listed (near the bottom) of our unit's webpage. From coopea04@csse.uwa.edu.au Fri Oct 30 11:25:19 2015 Date: Fri Oct 30 11:25:19 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.122 Subject: Late submission penalties? From: "Adrian Cooper" <20786307@student.uwa.edu.au> X-smilie: none X-img: none Was just about to post it, 20% per day From graven01@csse.uwa.edu.au Fri Oct 30 11:55:30 2015 Date: Fri Oct 30 11:55:30 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Late submission penalties? From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none "Adrian Cooper" <20786307@student.uwa.edu.au> wrote: > Was just about to post it, 20% per day (or part there of) ! very harsh IMO but hey deadlines are deadlines :D From maoy03@csse.uwa.edu.au Fri Oct 30 14:49:27 2015 Date: Fri Oct 30 14:49:27 2015 To: help2002@csse.uwa.edu.au Received: from 220.245.6.16 Subject: 2014 final exam solutions From: "Yuxuan Mao" <21190589@student.uwa.edu.au> X-smilie: gasp.png X-img: none Hi Just want to know will we have the solutions for the 2014 final exam? Cheers From fetzee01@csse.uwa.edu.au Fri Oct 30 14:50:21 2015 Date: Fri Oct 30 14:50:21 2015 To: help2002@csse.uwa.edu.au Received: from 122.111.245.242 Subject: 2014 final exam solutions From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none no From 00014979@csse.uwa.edu.au Mon Nov 2 06:30:50 2015 Date: Mon Nov 2 06:30:50 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: Project-2 information From: "Christopher McDonald" X-smilie: none X-img: none X-announcefor: 10d A sample solution for Project-2 is now available from the project's webpage. Marking so far: 90 submissions by 144 students; 10 did not compile; 2 could not be repaired. As our final exam is one of the first of the exam period, the marks for Project-2 WILL NOT be available before the final exam, so please don't ask or keep checking for them. We'll send an email to all when they're available. Good luck, From graven01@csse.uwa.edu.au Mon Nov 2 10:38:16 2015 Date: Mon Nov 2 10:38:16 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: 2014 final exam solutions From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none ...Was that an official answer? i would also like to see some sample solutions especially for the questions that don't involve writing code. to give an example of what is expected. From ahmedm07@csse.uwa.edu.au Mon Nov 2 12:04:49 2015 Date: Mon Nov 2 12:04:49 2015 To: help2002@csse.uwa.edu.au Received: from 120.156.144.19 Subject: Project 2 - Sample Solution From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none So. I like the solution. Looks way too clean and awesome and is making me pretty jealous to say the least. Anyhow, small issue. I tried compiling it. This is what i get, i am on ubuntu btw in case that might make a difference. Doubt it will though. cc -std=c99 -Wall -pedantic -o mysh mysh.o globals.o execute.o parser.o step1_simple_command.o step2_search_path.o step3_10_internal_command.o step4_sequential.o step5_background.o step6_subshell.o step7_file_redirection.o step8_pipeline.o step9_shellscript.o step1_simple_command.o: In function `execute_simple_command': step1_simple_command.c:(.text+0x8d): undefined reference to `WEXITSTATUS' step6_subshell.o: In function `execute_subshell': step6_subshell.c:(.text+0x8d): undefined reference to `WEXITSTATUS' step8_pipeline.o: In function `execute_pipeline': step8_pipeline.c:(.text+0x122): undefined reference to `WEXITSTATUS' collect2: error: ld returned 1 exit status make: *** [mysh] Error 1 From fetzee01@csse.uwa.edu.au Mon Nov 2 16:39:00 2015 Date: Mon Nov 2 16:39:00 2015 To: help2002@csse.uwa.edu.au Received: from 122.111.255.238 Subject: 2014 final exam solutions From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none Chris said in one of the lectures that solutions wouldn't be provided From bradfj01@csse.uwa.edu.au Mon Nov 2 20:25:05 2015 Date: Mon Nov 2 20:25:05 2015 To: help2002@csse.uwa.edu.au Received: from 60.224.9.24 Subject: 2014 final exam solutions From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > ...Was that an official answer? i would also like to see some sample solutions especially > for the questions that don't involve writing code. to give an example of what is expected. Considering there are questions, and there are answers to those questions in the lecture material. What is holding you back from actually researching the answers. Sorry to be blunt, but I realised that we are no longer being spoon fed. From 00014979@csse.uwa.edu.au Mon Nov 2 16:30:50 2015 Date: Mon Nov 2 16:30:50 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: Project 2 - Sample Solution From: "Christopher McDonald" X-smilie: none X-img: none Thanks for letting me know. The sample solution was only for OS-X, but I've now updated it for Linux, too. It just required the inclusion of to provide WEXITSTATUS. From lopasb03@csse.uwa.edu.au Tue Nov 3 05:44:42 2015 Date: Tue Nov 3 05:44:42 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.187.2 Subject: Project 2 - Sample Solution From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: biggrin.png X-img: none "Maktoom Ahmed" <21728592@student.uwa.edu.au> wrote: > So. I like the solution. Looks way too clean and awesome and is making me pretty > jealous to say the least. Anyhow, small issue. I tried compiling it. This is what i > get, i am on ubuntu btw in case that might make a difference. Doubt it will though. > > > cc -std=c99 -Wall -pedantic -o mysh mysh.o globals.o execute.o parser.o > step1_simple_command.o step2_search_path.o step3_10_internal_command.o > step4_sequential.o step5_background.o step6_subshell.o step7_file_redirection.o > step8_pipeline.o step9_shellscript.o > step1_simple_command.o: In function `execute_simple_command': > step1_simple_command.c:(.text+0x8d): undefined reference to `WEXITSTATUS' > step6_subshell.o: In function `execute_subshell': > step6_subshell.c:(.text+0x8d): undefined reference to `WEXITSTATUS' > step8_pipeline.o: In function `execute_pipeline': > step8_pipeline.c:(.text+0x122): undefined reference to `WEXITSTATUS' > collect2: error: ld returned 1 exit status > make: *** [mysh] Error 1 I don't know why you're having a problem, the sample solution works fine for me. All I did was unzip the contents of the .zip folder into a file called myshsol, for example, then go to that directory and type 'make' at the prompt, then ./mysh and it works like it is supposed to. Cheers, Ben. c",) From graven01@csse.uwa.edu.au Tue Nov 3 07:11:55 2015 Date: Tue Nov 3 07:11:55 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: 2014 final exam solutions From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > ANONYMOUS wrote: > > > ...Was that an official answer? i would also like to see some sample solutions especially > > for the questions that don't involve writing code. to give an example of what is expected. > > Considering there are questions, and there are answers to those questions in the lecture material. > What is holding you back from actually researching the answers. Sorry to be blunt, but I realised > that we are no longer being spoon fed. i was looking for hints to what would be expected , and the amount of detail that wold be required for full marks on one of the other questions, not so much the answers. Have a nice day. From nelsoj07@csse.uwa.edu.au Tue Nov 3 07:52:40 2015 Date: Tue Nov 3 07:52:40 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: 2014 final exam solutions From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > ANONYMOUS wrote: > > > ANONYMOUS wrote: > > > > > ...Was that an official answer? i would also like to see some sample solutions especially > > > for the questions that don't involve writing code. to give an example of what is expected. > > > > Considering there are questions, and there are answers to those questions in the lecture material. > > What is holding you back from actually researching the answers. Sorry to be blunt, but I realised > > that we are no longer being spoon fed. > > i was looking for hints to what would be expected , and the amount of detail that wold be required for > full marks on one of the other questions, not so much the answers. Have a nice day. Hey mate, if you're looking for just that then I'd suggest checking out the recording of the last lecture, Chris went over it well I thought. See how you go :) From graven01@csse.uwa.edu.au Tue Nov 3 09:38:15 2015 Date: Tue Nov 3 09:38:15 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: 2014 final exam solutions From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none yeah, i watched it, as stated it was the non-coding questions i was looking at sample for, oh well thanks anyway. From led05@csse.uwa.edu.au Tue Nov 3 11:32:36 2015 Date: Tue Nov 3 11:32:36 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.108.214 Subject: The banter was great From: "Henry Le" <21317911@student.uwa.edu.au> X-smilie: none X-img: none Goodluck to everyone doing this unit. I feel this video captures my feeling for the forum discussion this semester https://www.youtube.com/watch?v=GYmKqlmfQNA From ahmedm07@csse.uwa.edu.au Tue Nov 3 12:03:34 2015 Date: Tue Nov 3 12:03:34 2015 To: help2002@csse.uwa.edu.au Received: from 120.156.144.19 Subject: Project 2 - Sample Solution From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none "Benjamin Lopas" <19922921@student.uwa.edu.au> wrote: > "Maktoom Ahmed" <21728592@student.uwa.edu.au> wrote: > > > So. I like the solution. Looks way too clean and awesome and is making me pretty > > jealous to say the least. Anyhow, small issue. I tried compiling it. This is what i > > get, i am on ubuntu btw in case that might make a difference. Doubt it will though. > > > > > > cc -std=c99 -Wall -pedantic -o mysh mysh.o globals.o execute.o parser.o > > step1_simple_command.o step2_search_path.o step3_10_internal_command.o > > step4_sequential.o step5_background.o step6_subshell.o step7_file_redirection.o > > step8_pipeline.o step9_shellscript.o > > step1_simple_command.o: In function `execute_simple_command': > > step1_simple_command.c:(.text+0x8d): undefined reference to `WEXITSTATUS' > > step6_subshell.o: In function `execute_subshell': > > step6_subshell.c:(.text+0x8d): undefined reference to `WEXITSTATUS' > > step8_pipeline.o: In function `execute_pipeline': > > step8_pipeline.c:(.text+0x122): undefined reference to `WEXITSTATUS' > > collect2: error: ld returned 1 exit status > > make: *** [mysh] Error 1 > > I don't know why you're having a problem, the sample solution works fine for me. All I > did was unzip the contents of the .zip folder into a file called myshsol, for example, > then go to that directory and type 'make' at the prompt, then ./mysh and it works like > it is supposed to. Cheers, Ben. c",) I am not having a problem now either. Probably because Chris ported it. :) From newmal01@csse.uwa.edu.au Tue Nov 3 15:57:06 2015 Date: Tue Nov 3 15:57:06 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: 2014 final exam solutions From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > yeah, i watched it, as stated it was the non-coding questions i was looking at sample for, oh well thanks anyway. http://teaching.csse.uwa.edu.au/units/CITS2002/labsheets/labsheet6-solns.php heres the solution From bradfj01@csse.uwa.edu.au Tue Nov 3 17:33:07 2015 Date: Tue Nov 3 17:33:07 2015 To: help2002@csse.uwa.edu.au Received: from 60.224.9.24 Subject: The banter was great From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > Goodluck to everyone doing this unit. > I feel this video captures my feeling for the forum discussion this semester > https://www.youtube.com/watch?v=GYmKqlmfQNA Seems a slight bit ironic since you are posting as anonymous ;) From led05@csse.uwa.edu.au Tue Nov 3 19:06:55 2015 Date: Tue Nov 3 19:06:55 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.219.38 Subject: The banter was great From: "Henry Le" <21317911@student.uwa.edu.au> X-smilie: none X-img: none that's the point hahaha From johnsd16@csse.uwa.edu.au Wed Nov 4 11:12:38 2015 Date: Wed Nov 4 11:12:38 2015 Edit: Wed Nov 4 11:13:20 2015 To: help2002@csse.uwa.edu.au Received: from 121.45.239.128 Subject: 2d arrays and pointers From: "Dylan Johnson" <21469038@student.uwa.edu.au> X-smilie: none X-img: none Hi Chris, I've noticed whenever you do an example involving 2d arrays you tend to represent them with a pointer-to-pointer, however everything else I've read on the subject suggests this is bad practice. I know that 1d arrays can be accessed through a pointer since all the elements are the same size and you just have to add a predefined amount to the address to reach the next element, and as far as I know the compiler will translate pointer[x] into * (pointer + x). But as far as I understand it this won't hold true for 2d arrays if each 1d array inside it is a different size. For this reason I'm unclear on whether the elements in a 2d array passed as a pointer-to-pointer can be accessed using the x[i][j] type of syntax. Likewise, does this syntax work for dynamically allocated arrays where the elements might not be stored contiguously? Lastly, when a 2d array is passed to a function and it decays into a pointer, does it decay into a pointer of type "something[array]", or does it decay a second time into a pointer to the first element in the first array of the 2d structure? Much appreciate any clarification given. From newmal01@csse.uwa.edu.au Wed Nov 4 17:05:26 2015 Date: Wed Nov 4 17:05:26 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: comments From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none unless the question asks us for it are we expected to include comments in our exam for the code questions? From graven01@csse.uwa.edu.au Wed Nov 4 17:09:01 2015 Date: Wed Nov 4 17:09:01 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: comments From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none to add, if we aren't quite sure of the code is it best to include pseudo code? for eg. for(int i = 0 ; i< 231; i++ ) // loop through array replacing the first word of each string. From newmal01@csse.uwa.edu.au Wed Nov 4 17:29:18 2015 Date: Wed Nov 4 17:29:18 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.154.137 Subject: EXAM CLARIFICATIONS From: "Lachlan Newman" <21107195@student.uwa.edu.au> X-smilie: none X-img: none if we are asked to write a function are we to assume that nothing hs happed in the main function besides calling the function unless told otherwise? From led05@csse.uwa.edu.au Wed Nov 4 21:02:53 2015 Date: Wed Nov 4 21:02:53 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.69.149 Subject: EXAM CLARIFICATIONS From: "Henry Le" <21317911@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > if we are asked to write a function are we to assume that nothing hs happed in the > main function besides calling the function unless told otherwise? Hey, As I understand it, we'd be writing a certain function to do the specific task and that's it. It would be a different story if we were asked to write a program that does the same thing, in which case we'd include the main function our selves. We don't know if the function is the main part of the program, it could be passing a result to another function to be used before it goes to main, so maybe don't worry too much about what's going to be called in main :) From 00014979@csse.uwa.edu.au Thu Nov 5 04:43:19 2015 Date: Thu Nov 5 04:43:19 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: EXAM CLARIFICATIONS From: "Christopher McDonald" X-smilie: none X-img: none Henry's reply is a good one. You'll be asked to write a function or functions, in isolation - they may be called from anywhere, not necessarily from main(). You'll be informed what the function has to do, the datatypes and role of the parameters, what datatype it returns, and what the function should do if any parameters are invalid or the function hits an error. (actually I'm unsure what you're expecting/fearing to happen before the function is called?) From 00014979@csse.uwa.edu.au Thu Nov 5 05:28:30 2015 Date: Thu Nov 5 05:28:30 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: comments From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > unless the question asks us for it are we expected to include comments in > our exam for the code questions? *Expected* to add comments - no. However the real question is - why wouldn't you add comments? One role of an exam is for you to explain to the examiner what you understand; one role of a solid programmer is to explain to other programmers what your program does. In this unit the roles are very similar. Good programming practices don't just apply to 'real' programs running on a computer, they also apply to the ways we communicate programs - in design, documentation, and exams(!) This applies not just to comments, but to choice of identifier names that will help the examiner understand your work, choice of bounded.vs.unbounded loops, possibly adding a small "helper" function, and so on. What is *not* expected is the perfect use of punctuation, matching brackets, etc - recognising that exams are stressful, and that the "little things" could have been trivially resolved if the exam was undertaken on a computer. But don't confuse that concession with the thought that your exam solutions shouldn't employ good programming practices. From 00014979@csse.uwa.edu.au Thu Nov 5 05:36:24 2015 Date: Thu Nov 5 05:36:24 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: comments From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > to add, if we aren't quite sure of the code is it best to include pseudo code? Writing pseudo-code is certainly better than writing nothing but, of course, the more "pseudo" it is, the less it's answering the question in the spirit of the unit's exam. From 00014979@csse.uwa.edu.au Thu Nov 5 06:55:36 2015 Date: Thu Nov 5 06:55:36 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: 2d arrays and pointers From: "Christopher McDonald" X-smilie: none X-img: none "Dylan Johnson" <21469038@student.uwa.edu.au> wrote: Hi Dylan, A good meaty question; I thought others may have jumped in to answer it :-) > Hi Chris, I've noticed whenever you do an example involving 2d arrays you tend to > represent them with a pointer-to-pointer, however everything else I've read on the > subject suggests this is bad practice. I don't believe your premise, which suggests that one method can be favoured over another. The sample solution for the 1st project used 2D arrays, without a pointer in sight. I don't think I've ever read that using a pointer-to-a-pointer is a bad practice, because there are many situations for which it's the correct (only?) choice, but it's certainly a bad practice to just arbitrarily mix them because they have different memory layouts. The appended C program may demonstrate the different layout of the two "approaches", showing that their elements have very different address structures. > But as far as I understand it this won't hold true for 2d arrays if each 1d array > inside it is a different size. For this reason I'm unclear on whether the elements in > a 2d array passed as a pointer-to-pointer can be accessed using the x[i][j] type of > syntax. Likewise, does this syntax work for dynamically allocated arrays where the > elements might not be stored contiguously? > Lastly, when a 2d array is passed to a function and it decays into a pointer, does it > decay into a pointer of type "something[array]", or does it decay a second time into a > pointer to the first element in the first array of the 2d structure? I'm not familiar with that use of the word 'decay' - perhaps from a specific textbook? All function parameters in C, whether they're simple scalar types, structures, or arrays/pointers, are copied by value before being received by a function. (Other than for type promotion of integers and doubles) the format or representation of the parameters doesn't change. Passing an array, either by just using its name, or a pointer to the first element of the array, will just copy that address to the function's parameter - no other information, such as the dimensions of the array, is passed. So, unless the dimensions of each dimension are provided in the function's prototype, or passed as additional integer arguments, then the function doesn't know about the array's memory layout. Passing a regular 2D (rectangular) array and passing an array of pointers to different length 1D arrays will be unsuccessful, because their layouts in memory are different. #include #include #define NR 3 #define NC 4 int main(int argc, char *argv[]) { int j = 0; int a[NR][NC]; j = 0; for(int r=0 ; r X-smilie: none X-img: none Does this mean we are limited to writing only the function/s specified in the question? Or can we write separate functions that are called from the function specified (like how the concordance solution in labsheet 6 has a few functions)? From 00014979@csse.uwa.edu.au Thu Nov 5 12:53:49 2015 Date: Thu Nov 5 12:53:49 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: EXAM CLARIFICATIONS From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Does this mean we are limited to writing only the function/s specified in the question? > Or can we write separate functions that are called from the function specified (like how the concordance > solution in labsheet 6 has a few functions)? Additional functions, often termed "helper functions" are fine, and often a good idea to avoid adding complications to a single function. In the sample solution for the 2nd project, I used one named execute_pathname() for Step 2. From bradfj01@csse.uwa.edu.au Thu Nov 5 13:27:10 2015 Date: Thu Nov 5 13:27:10 2015 To: help2002@csse.uwa.edu.au Received: from 49.196.8.153 Subject: Coding part in 2013 exam From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none Hi, The questions asks to create a function to test if there's a (needle) substring pointer in a (haystack) string pointer and I wanted to check if my logic is correct. Firstly I was thinking of looping through the haystack, taking a temp variable of the index to indicate the starting index where the needle's first character equals the haystack's current character. I then do a while loop for while the needle and haystack does not equal a null byte I want to check if the characters are equal as the haystack and needle increment. If the whole loop is unsuccessful I want to break and keep trying by moving to the next index after the temporary held start index. If the whole loop completes correctly without any breaks I want to return true otherwise false. Have I just overtly complicated it all D: Thank you in advance :) From nelsoj07@csse.uwa.edu.au Thu Nov 5 14:28:38 2015 Date: Thu Nov 5 14:28:38 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: Coding part in 2013 exam From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none "Jamie Bradford" <21499608@student.uwa.edu.au> wrote: > Hi, > > The questions asks to create a function to test if there's a (needle) substring pointer > in a (haystack) string pointer and I wanted to check if my logic is correct. Firstly I > was thinking of looping through the haystack, taking a temp variable of the index to > indicate the starting index where the needle's first character equals the haystack's > current character. > > I then do a while loop for while the needle and haystack does not equal a null byte I > want to check if the characters are equal as the haystack and needle increment. > > If the whole loop is unsuccessful I want to break and keep trying by moving to the next > index after the temporary held start index. If the whole loop completes correctly without > any breaks I want to return true otherwise false. > > Have I just overtly complicated it all D: > > Thank you in advance :) Hey, Sounds like that is similar ( the same? ) as strstr, which we recreate in Lab 5, Question 1.g. I don't think there's an example solution but I don't think your idea is too far off! :) I did that today so can send you my attempts if you like. I approach it similarly, if I'm understanding you correctly. Have you given it a go at writing it through? How'd you go? P.S. I don't think 2013 was quite the same unit, so might be easier to stick to the 2014 exam :) From maoy03@csse.uwa.edu.au Thu Nov 5 15:40:48 2015 Date: Thu Nov 5 15:40:48 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.121 Subject: Coding part in 2013 exam From: "Yuxuan Mao" <21190589@student.uwa.edu.au> X-smilie: none X-img: none hi where did you find 2013 exam paper? From ahmedm07@csse.uwa.edu.au Thu Nov 5 16:23:46 2015 Date: Thu Nov 5 16:23:46 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.65.198 Subject: Coding part in 2013 exam From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none http://onesearch.library.uwa.edu.au/primo_library/libweb/action/search.do?mode=Basic&vid=UWA&tab=examination_papers& Probably try searching the words " C Programming " From bradfj01@csse.uwa.edu.au Thu Nov 5 16:43:56 2015 Date: Thu Nov 5 16:43:56 2015 To: help2002@csse.uwa.edu.au Received: from 49.196.8.153 Subject: Coding part in 2013 exam From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > "Jamie Bradford" <21499608@student.uwa.edu.au> wrote: > > > Hi, > > > > The questions asks to create a function to test if there's a (needle) substring pointer > > in a (haystack) string pointer and I wanted to check if my logic is correct. Firstly I > > was thinking of looping through the haystack, taking a temp variable of the index to > > indicate the starting index where the needle's first character equals the haystack's > > current character. > > > > I then do a while loop for while the needle and haystack does not equal a null byte I > > want to check if the characters are equal as the haystack and needle increment. > > > > If the whole loop is unsuccessful I want to break and keep trying by moving to the next > > index after the temporary held start index. If the whole loop completes correctly without > > any breaks I want to return true otherwise false. > > > > Have I just overtly complicated it all D: > > > > Thank you in advance :) > > Hey, > > Sounds like that is similar ( the same? ) as strstr, which we recreate in Lab 5, Question 1.g. > > I don't think there's an example solution but I don't think your idea is too far off! :) > > I did that today so can send you my attempts if you like. I approach it similarly, if I'm > understanding you correctly. > > Have you given it a go at writing it through? How'd you go? > > P.S. I don't think 2013 was quite the same unit, so might be easier to stick to the 2014 exam :) Thanks Jake :) I'm at work so I think I'll give it a try tonight. I'm thinking it might be a question to do with allocating memory may be. Or even, some stuff we have done in the project/labs. I'm putting my bet on the function we have to right definitely working with pointers because to some it might be a hard concept to use. TBH I think I'm fine with pointers but nonetheless I'm going to be studying my butt off still. Thanks for the feedback :3 From heinsm01@csse.uwa.edu.au Thu Nov 5 21:02:55 2015 Date: Thu Nov 5 21:02:55 2015 To: help2002@csse.uwa.edu.au Received: from 126.221.7.17 Subject: 2d arrays and pointers From: "Matthew Heinsen Egan" <10430227@student.uwa.edu.au> X-smilie: none X-img: none "Dylan Johnson" <21469038@student.uwa.edu.au> wrote: > Lastly, when a 2d array is passed to a function and it decays into a pointer, does it > decay into a pointer of type "something[array]", or does it decay a second time into a > pointer to the first element in the first array of the 2d structure? Hi Dylan, The text from the standard (for C11) concerning this is (from 6.3.2.1 (3)): > Except when it is the operand of the sizeof operator, the _Alignof operator, or the > unary & operator, or is a string literal used to initialize an array, an expression that has > type "array of type" is converted to an expression with type "pointer to type" that points > to the initial element of the array object and is not an lvalue. In the case of a 2d array, after the first type conversion the expression will have type "pointer to array type". There's no further type conversion. You can check this with your compiler by doing something like: void test(char *a) {} ... char a[10][10]; test(a); Note that the type conversion is not a specific case for passing to functions. So a simpler test could be: char a[10][10]; char *aptr = a; From lopasb03@csse.uwa.edu.au Fri Nov 6 14:11:02 2015 Date: Fri Nov 6 14:11:02 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.187.2 Subject: Semester 2, 2014 Examination, Question 6 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Does any body have a solution to this question, or know where one is, I missed out on seeing the last years students attempt because the video cut out and I was still doing Project 2 so I couldn't attend the lecture, and I want to compare it with my solution. Can somebody please post it in this forum, or explain how a solution is achieved or written, I am a little confused by it. Cheers, Ben. c",) From nelsoj07@csse.uwa.edu.au Fri Nov 6 14:43:28 2015 Date: Fri Nov 6 14:43:28 2015 Edit: Fri Nov 6 14:44:54 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: Semester 2, 2014 Examination, Question 6 From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: a0307c5907a810a8e019477516a7f424.c This is my fairly inelegant solution, compiles and works on Mac for me. No warranty! :) #include #include #include #include #include #include #define MAXSIZE 100 int removeDirectory(char * directoryname) { int status = 0; DIR * dirp; struct dirent * dp; if (rmdir(directoryname) != 0) { if (unlink(directoryname) != 0) { dirp = opendir(directoryname); if ( dirp == NULL ) { fprintf(stderr,"Could not open : %s\n", directoryname); return 1; } while ( (dp = readdir(dirp) ) != NULL) { if (strcmp(dp->d_name, ".") == 0) { continue; } if (strcmp(dp->d_name, "..") == 0) { continue; } if (rmdir(dp->d_name) != 0) { if (unlink(dp->d_name) != 0) { char nextfolder[MAXSIZE]; strcpy(nextfolder,directoryname); strcat(nextfolder,"/"); strcat(nextfolder,dp->d_name); status = removeDirectory(nextfolder); } } } closedir(dirp); } if (unlink(directoryname) != 0) { status = rmdir(directoryname); } } return status; } int main(int argc, char * argv[]) { int exitstatus = 0; if (argv[1] != NULL) { exitstatus = removeDirectory(argv[1]); } return exitstatus; } From kahwan01@csse.uwa.edu.au Fri Nov 6 14:58:47 2015 Date: Fri Nov 6 14:58:47 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.231.106 Subject: Regarding the exam tomorrow From: "Nerces Kahwajian" <21592645@student.uwa.edu.au> X-smilie: none X-img: c3c3bb2847a5fe904642230cddb73bbb.jpeg Why From sembir01@csse.uwa.edu.au Fri Nov 6 14:59:46 2015 Date: Fri Nov 6 14:59:46 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.179.150 Subject: Regarding the exam tomorrow From: "Rajkaran Sembi" <21519782@student.uwa.edu.au> X-smilie: none X-img: f7bddd22d8c4c9207eb24f3abe13739d.png ANONYMOUS wrote: > Why How do you programming? From nelsoj07@csse.uwa.edu.au Fri Nov 6 15:04:58 2015 Date: Fri Nov 6 15:04:58 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: Regarding the exam tomorrow From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: ce874d2549a57335f370d7ecdb251471.jpeg Guys, prep time: From lopasb03@csse.uwa.edu.au Fri Nov 6 15:46:53 2015 Date: Fri Nov 6 15:46:53 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.187.2 Subject: Semester 2, 2014 Examination, Question 6 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none Thanks Jon Snow, Um I mean Jake Nelson. c",) From 00014979@csse.uwa.edu.au Fri Nov 6 15:48:12 2015 Date: Fri Nov 6 15:48:12 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.1.70 Subject: Semester 2, 2014 Examination, Question 6 From: "Christopher McDonald" X-smilie: none X-img: none Now, the right thing would be for Ben to offer his solution.... From gallj01@csse.uwa.edu.au Fri Nov 6 15:24:53 2015 Date: Fri Nov 6 15:24:53 2015 To: help2002@csse.uwa.edu.au Received: from 60.224.41.128 Subject: Freeway disruptions - getting to Saturday's exam From: "James Gall" <21498933@student.uwa.edu.au> X-smilie: none X-img: none X-announcefor: 1d If anyone isn't aware, over this weekend the Joondalup train line isn't running between Whitfords and Perth, meaning that those of us who would normally use it to get into Uni will be catching replacement buses. That'll mean a longer trip, so make sure you're aware of that when deciding what time to leave tomorrow. You can check out the details on the transperth website. From: "Jason Ankers" <21493118@student.uwa.edu.au> Thanks James From: "Christopher McDonald" Thanks for posting this James, very helpful. Here's the official word about all trains being stopped, and cars being limited to two lanes: https://www.mainroads.wa.gov.au/AboutMainRoads/News/Pages/mitchellfwy.aspx From lopasb03@csse.uwa.edu.au Fri Nov 6 16:45:37 2015 Date: Fri Nov 6 16:45:37 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.187.2 Subject: Semester 2, 2014 Examination, Question 6 From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > Now, the right thing would be for Ben to offer his solution.... There would be really no point *ANONYMOUS* as it turns out my solution was seriously flawed and not even finished. Cheers, ANONYMOUS. c",) From liaoj02@csse.uwa.edu.au Fri Nov 6 17:27:55 2015 Date: Fri Nov 6 17:27:55 2015 To: help2002@csse.uwa.edu.au Received: from 43.252.114.2 Subject: EXAM CLARIFICATIONS From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none "Christopher McDonald" wrote: > ANONYMOUS wrote: > > > Does this mean we are limited to writing only the function/s specified in the question? > > Or can we write separate functions that are called from the function specified (like how the concordance > > solution in labsheet 6 has a few functions)? > > Additional functions, often termed "helper functions" are fine, and often a good idea to avoid adding complications > to a single function. > In the sample solution for the 2nd project, I used one named execute_pathname() for Step 2. Hello Chris. Do we have to include header file when calling library function? From nelsoj07@csse.uwa.edu.au Fri Nov 6 18:33:13 2015 Date: Fri Nov 6 18:33:13 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: Semester 2, 2014 Examination, Question 6 From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Haha no problem. I think my solution is not necessarily the most elegant, and would actually probably look into using the stat() family to simplify it somewhat. Lecture 20 is helpful though :) From led05@csse.uwa.edu.au Fri Nov 6 19:18:00 2015 Date: Fri Nov 6 19:18:00 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.69.149 Subject: Semester 2, 2014 Examination, Question 6 From: "Henry Le" <21317911@student.uwa.edu.au> X-smilie: none X-img: none Hey Jake, Your solution looks sound, I spoke with Chris after the tute and he said that checking for the attributes of the file is important, seeing as we may not have permissions to unlink or rmdir (even though the qu says assume only file and directories LOL). One I would like to mention is maybe you could shorten the building of the string by using sprintf rather than using copy and cat multiple times, just easier to format and simpler IMO. Aside from that I think your solution looks very good! From led05@csse.uwa.edu.au Fri Nov 6 19:21:53 2015 Date: Fri Nov 6 19:21:53 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.69.149 Subject: EXAM CLARIFICATIONS From: "Henry Le" <21317911@student.uwa.edu.au> X-smilie: none X-img: none hey, It's not imperative, but it can help you get some marks if you use appropriate libraries. I'm paraphrasing here but Chris' comments on one of the not to good answers "He could've just added some header files" From nelsoj07@csse.uwa.edu.au Fri Nov 6 20:48:55 2015 Date: Fri Nov 6 20:48:55 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: Semester 2, 2014 Examination, Question 6 From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none Thanks Henry, appreciate the feedback! Here's v2.0, still probably with room for improvement but now with added stat()! #include #include #include #include #include #include #define MAXSIZE 100 int removeDirectory(char * directoryname) { int status = 0; DIR * dirp; struct dirent * dp; struct stat sp; if (rmdir(directoryname) != 0) { dirp = opendir(directoryname); if ( dirp == NULL ) { fprintf(stderr,"Could not open : %s\n", directoryname); return 1; } while ( (dp = readdir(dirp) ) != NULL) { if (strcmp(dp->d_name, ".") == 0) { continue; } if (strcmp(dp->d_name, "..") == 0) { continue; } char next[MAXSIZE]; strcpy(next,directoryname); strcat(next,"/"); strcat(next,dp->d_name); if ( stat(next, &sp) != 0 ) { fprintf(stderr,"Could not check file or folder details for %s\n", dp->d_name); return 1; } else if (S_ISREG(sp.st_mode)) { if(unlink(next) != 0) { return 1; } } else if (S_ISDIR(sp.st_mode)) { status = removeDirectory(next); // return status; } } closedir(dirp); status = rmdir(directoryname); } return status; } int main(int argc, char * argv[]) { int exitstatus = 0; if (argv[1] != NULL) { exitstatus = removeDirectory(argv[1]); } return exitstatus; } From 00014979@csse.uwa.edu.au Sat Nov 7 05:11:45 2015 Date: Sat Nov 7 05:11:45 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: EXAM CLARIFICATIONS From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Hello Chris. Do we have to include header file when calling library function? The answer to this is exactly the same as for the other question about including comments - why wouldn't you? If you're aware that a program, even a short function, requires standard external functions, such as strcpy, malloc, exit, .... then by adding the #include statements to your exam solution you're demonstrating your knowledge to the marker that these are required to make a better/working function. They don't need to have their perfectly correct names, just something close that shows you have the knowledge. From chowda01@csse.uwa.edu.au Sat Nov 7 07:29:54 2015 Date: Sat Nov 7 07:29:54 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.112.22 Subject: EXAM CLARIFICATIONS From: "Anirban Chowdhury" <21432966@student.uwa.edu.au> X-smilie: none X-img: none Are we strictly allowed to use pencils for writing all our answers? thanks From devilf01@csse.uwa.edu.au Sat Nov 7 08:50:32 2015 Date: Sat Nov 7 08:50:32 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.179.211 Subject: Regarding the exam tomorrow From: "Friedel de Villiers" <10308548@student.uwa.edu.au> X-smilie: none X-img: 8f6ba6731426289b4fc7c90930caf312.jpg "Rajkaran Sembi" <21519782@student.uwa.edu.au> wrote: > ANONYMOUS wrote: > > > Why > > How do you programming? From 00014979@csse.uwa.edu.au Sat Nov 7 09:09:01 2015 Date: Sat Nov 7 09:09:01 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: EXAM CLARIFICATIONS From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Are we strictly allowed to use pencils for writing all our answers? If you want; just keep it readable. From bradfj01@csse.uwa.edu.au Sat Nov 7 10:03:36 2015 Date: Sat Nov 7 10:03:36 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.183.198 Subject: Coding part in 2013 exam From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: sorcerer.png X-img: none If you're wanting a solution I think I have created one? I have tested it quite a few times now and it seems to be working :D huzzah! #include #include #include /* CITS2002 Question from 2013 examination. Date: Saturday 7th November, 2015 Author: Jamie Bradford. */ /* substr_test is a checker, it checks whether a substring is within a string if the substring is within, 0 is returned. If not, 1 is returned. */ int substr_test(char *str, char *src) { //loop through each character of the string. for(int i = 0; i < strlen(str); ++i) { //hold temp to retrieve after loop of substring. int temp = i; int j = 0; //while both do not equal \0, to make sure no index out of bounds. while(src[j] != '\0' || str[i] != '\0') { //if we come across an invalid match, break the loop. if(str[i] != src[j]) { break; } //otherwise continue to increment the dtring and substring index. ++i; ++j; } //obviously if the counter of current index of substring is equal to //the length of the substring then it is within the string. if(j == strlen(src)) { return 0; } //otherwise we will start at the next index of string that we started with. i = temp; } //looped through everything, therefore the substring does not match! return 1; } //--------------------------------------------------------------------------------- /* Main will call the function to test whether the scanned input substring is within the string, print the results (whether in or not in) and ask the user whether they would like to continue. */ int main(int argc, char *argv[]) { //Program will loop until user types 1 for exit. int response = 0; while(response != 1) { //initializations... char *str; char *src; char ar1 [20]; char ar2 [20]; str = ar1; src = ar2; //get str printf("Please enter the string: \n"); scanf("%s", str); //get src printf("Please enter a substring to search for: \n"); scanf("%s", src); //get the returned value of substr. int value = substr_test(str, src); if(value == 0) { //0 = yes it is within. printf("The substring - %s, is within the string - %s\n", src, str); } else { //1 = no it is not within. printf("The substring - %s, is NOT within the string - %s\n", src, str); } //ask if the user would like to continue. printf("Would you like to continue?\n\n"); printf("yes - 0 no - 1\n"); scanf("%i", &response); } return 0; } From nelsoj07@csse.uwa.edu.au Sat Nov 7 10:48:18 2015 Date: Sat Nov 7 10:48:18 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.200.0 Subject: Coding part in 2013 exam From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: none X-img: none My attempt with pointers: char *strstr_p(char * first, char * second) { char * location = NULL; int same = 1; while ( *first != '\0' ) { char *first_copy = first; char *second_copy = second; while ( * second_copy != '\0' ) { if (* first_copy == *second_copy) { same = 0; } else { same = 1; break; } ++first_copy; ++second_copy; } if (same == 0) { location = first; break; } ++first; } return location; With Arrays: char *strstr_a(char first[], char second[]) { char * location = NULL; int same = 1; int size_first = strlen(first); int size_second = strlen(second); for (int i = 0; i < size_first; ++i ) { for (int j = 0; j < size_second; ++j) { if (first[i+j] == second[j] ) { same = 0; } else { same = 1; } if (same == 1) { break; } } if (same == 0) { location = &first[i]; break; } } return location; } Looks good though :) From bradfj01@csse.uwa.edu.au Sat Nov 7 11:09:11 2015 Date: Sat Nov 7 11:09:11 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.183.198 Subject: Coding part in 2013 exam From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none Yeh that looks good as well! I don't know if it's me or not, but I find that pointers make the code look tidier and shorter, so I guess they're good for user readability. But then again, pointers are crazy if you don't know how to use them which I found out in the second project, I know how to use them now and learned fully how to use them in the project, however it was fun getting random results haha From mcfald01@csse.uwa.edu.au Sat Nov 7 16:29:51 2015 Date: Sat Nov 7 16:29:51 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.168.174 Subject: SSTF/SCAN/C-SCAN From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none Hey, I might have completely missed this part, where did we cover it? I was looking at it in the exam and it seemed completely foreign. I don't remember doing anything to do with disk scheduling! From bradfj01@csse.uwa.edu.au Sat Nov 7 16:32:01 2015 Date: Sat Nov 7 16:32:01 2015 To: help2002@csse.uwa.edu.au Received: from 10.20.185.77 Subject: Coding part in 2013 exam From: "Jamie Bradford" <21499608@student.uwa.edu.au> X-smilie: none X-img: none Hahahahaha so glad I did this question and got it to work :D From graven01@csse.uwa.edu.au Sat Nov 7 16:48:57 2015 Date: Sat Nov 7 16:48:57 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.180.64 Subject: Coding part in 2013 exam From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none wish i read this question before i went in, wasted a lot of time. think i wrote a double loop with an index variable. From graven01@csse.uwa.edu.au Sat Nov 7 16:51:27 2015 Date: Sat Nov 7 16:51:27 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.180.64 Subject: SSTF/SCAN/C-SCAN From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none ditto , but standard answer will be "Unit material only covers 1/3rd of what you need to know." From graven01@csse.uwa.edu.au Sat Nov 7 17:04:21 2015 Date: Sat Nov 7 17:04:21 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.180.64 Subject: See you next year! From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none I would have aced last years exam!!! all the "micro" tasks really took there toll,, i.e. breaking path into fields then appending programme, needle in he haystack with looping, recursive functions on directories, whinge over, see ya next year Chris, i did enjoy the unit. From lopasb03@csse.uwa.edu.au Sat Nov 7 17:44:36 2015 Date: Sat Nov 7 17:44:36 2015 To: help2002@csse.uwa.edu.au Received: from 58.7.187.2 Subject: SSTF/SCAN/C-SCAN From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > ditto , but standard answer will be "Unit material only covers 1/3rd of what you need to know." I don't know about that, I think it was an unfair question and no-one I know knew the answer. I booked out and read stallings book, I bought the recommended C book and read all the lecture notes many times and never came accross SSTF/SCAN/C-SCAN From fetzee01@csse.uwa.edu.au Sat Nov 7 17:52:45 2015 Date: Sat Nov 7 17:52:45 2015 To: help2002@csse.uwa.edu.au Received: from 122.111.255.238 Subject: SSTF/SCAN/C-SCAN From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > ANONYMOUS wrote: > > > ditto , but standard answer will be "Unit material only covers 1/3rd of what you need to know." > > > I don't know about that, I think it was an unfair question and no-one I know knew the answer. I > booked out and read stallings book, I bought the recommended C book and read all the lecture > notes many times and never came accross SSTF/SCAN/C-SCAN Yes, I actually bothered to read stallings, 7e, but I only read the chapters based on the material we covered. These points were never covered, I'm sure of it From fetzee01@csse.uwa.edu.au Sat Nov 7 17:53:36 2015 Date: Sat Nov 7 17:53:36 2015 To: help2002@csse.uwa.edu.au Received: from 122.111.255.238 Subject: Syntax Leniency in code questions From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none Hi Chris, Have some questions on the strictness of syntax in the coding questions: Regarding mistakes such as the following: instead of execv I accidently wrote execl ! So, one letter, even though I understood the question fully. This mistake would’ve made the program not compile but if I said execv instead, it would work perfectly. So I am asking if this is a great deal in loss of marks? Another mistake, in question 6, instead of .st_mtime I wrote s_mtime. I believe this should not be a deduction in marks at all, giving we are writing it. Thank you, the cohort. From ahmedm07@csse.uwa.edu.au Sat Nov 7 18:11:29 2015 Date: Sat Nov 7 18:11:29 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.18.232 Subject: SSTF/SCAN/C-SCAN From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > ANONYMOUS wrote: > > > ANONYMOUS wrote: > > > > > ditto , but standard answer will be "Unit material only covers 1/3rd of what you need to know." > > > > > > I don't know about that, I think it was an unfair question and no-one I know knew the answer. I > > booked out and read stallings book, I bought the recommended C book and read all the lecture > > notes many times and never came accross SSTF/SCAN/C-SCAN > > > Yes, I actually bothered to read stallings, 7e, but I only read the chapters based on the material we > covered. These points were never covered, I'm sure of it Also bought the Stalling, 7e Book. It does talk about SCAN, C-SCAN and N-Step-SCAN AND FSCAN as well as SSTF. However, I find it very hard to believe that we were supposed to learn that whole book. Considering the book was "recommended", its entirely unfair to ask questions about things that are not mentioned once in the lecture notes. Also, at the top of the schedule page, it reads this : "This schedule is now 'complete' - an accurate record of what we covered in 2015.". If that is an accurate record then anything not in that record should not be tested on. I understand that lecture notes cannot cover everything and that is something we as students must deal with however, it is not ok to not mention anything in lecture notes and expect us to know about it. If that is the case then were we also expected to have learnt about RAID, Concurrency, Deadlock and Starvation, Real-Time Scheduling, and a whole lot more since they have not been mentioned in lectures? From mitchc16@csse.uwa.edu.au Sat Nov 7 20:48:36 2015 Date: Sat Nov 7 20:48:36 2015 To: help2002@csse.uwa.edu.au Received: from 203.59.85.82 Subject: Syntax Leniency in code questions From: "Cameron Mitchell" <21514056@student.uwa.edu.au> X-smilie: none X-img: none "The C code and functions that you write will not be rigorously assessed for its syntactic accuracy, although clear use of identifier names, control-flow, and indentation, will be sought to assess the intention of your answers." - Final examination information page From mcfald01@csse.uwa.edu.au Sun Nov 8 05:44:22 2015 Date: Sun Nov 8 05:44:22 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.168.174 Subject: Syntax Leniency in code questions From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none I doubt they'd deduct anything for such a small error. Especially not for something as pedantic as s_mtime instead of st_mtime. It was clear you knew what you were doing, in a real scenario it would be trivial to look up the correct syntax. From abusha02@csse.uwa.edu.au Sun Nov 8 13:16:39 2015 Date: Sun Nov 8 13:16:39 2015 Edit: Sun Nov 8 13:29:16 2015 To: help2002@csse.uwa.edu.au Received: from 203.59.152.130 Subject: SSTF/SCAN/C-SCAN From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none I don't think that question was fair either. Just because something's in the textbook, it doesn't mean it's fair to assess us on it, especially when it's only a recommended reading material. I also have the book, and it's 20 chapters, with barely 6 of those chapters being relevant to the unit. We can't be expected to know everything in the book walking into the exam. The material on which we can be assessed should be determined by the topics covered in the lectures; I always took Chris' disclaimer about needing a book to mean that the lectures wouldn't cover any topics to the same level of depth to which we could be assessed, and that we'd need to read a book to learn that extra depth. I never took it to mean that he could assess us on topics that haven't been mentioned, just because they're in the book. He might as well have asked us about threads or Translation Lookaside Buffers, which are both logical extensions/sub-topics of topics we did learn. I know that reading the lecture notes and watching the lectures doesn't constitute everything we need to know for the unit, but that shouldn't mean that we can be assessed on something that hasn't been mentioned once in the unit. I've enjoyed this unit a lot, but I don't appreciate the fact that the unit's scope is so poorly defined; it's a train of thought that allows one to justify asking anything in the exam. I could argue that Chris should've asked us a question on assembly code, since it was even in one of the lecture notes. Relying on students reading the textbook is fine, but we still need some way to know what topics we're expected to know, or the unit's scope is just too undefined. And just to preemptively attack the argument that "there was a lecture on I/O management, so you can be assessed on I/O management related concepts," most of the OS topics covered in this unit are, on their own, behemoths of topics. We barely even scrape the surfaces of operating systems, and this unit provides us an insight into OS design principles more so than "teaching us" operating systems, which is what one would expect with the time-frame. That being the case, the argument that we should be able to answer a question pulled from one of the overarching topics in the unit falls apart, because there's no point at which that even stops (each topic branches off into several others, which branch further into even more topics etc.). That openness is exactly the reason a unit like this needs to be clearly defined; we as students don't know where the "unit" material stops, but Chris does. From graven01@csse.uwa.edu.au Sun Nov 8 13:33:53 2015 Date: Sun Nov 8 13:33:53 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: SSTF/SCAN/C-SCAN From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none with most people struggling with the question, the "bell curve" should sort it out. ? right? From liaoj02@csse.uwa.edu.au Sun Nov 8 15:13:54 2015 Date: Sun Nov 8 15:13:54 2015 Edit: Sun Nov 8 15:14:43 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.238.134 Subject: SSTF/SCAN/C-SCAN From: "Jia Liao" <21480279@student.uwa.edu.au> X-smilie: none X-img: none lol.. just 5 marks.. But yeah, good lesson for us to do self-reading. We got used to orthodox ways of teaching, which limit our motivation to learn though. From mcfald01@csse.uwa.edu.au Sun Nov 8 15:24:02 2015 Date: Sun Nov 8 15:24:02 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.168.174 Subject: SSTF/SCAN/C-SCAN From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none With that 1 question being so far out of scope, I think it's just an outlier and shouldn't be counted. As others have said it's very unreasonable to expect that range of preparation but I think this was a mistake rather than a lesson that you should do extensive pre-reading. In my eyes outside reading should be done more to gain depth for covered topics, not to learn topics that weren't covered (unless they're of personal interest). Hoping from a reply from Chris! Aside from this question I thought the exam was quite solid and of similar difficulty to the past paper. From ahmedm07@csse.uwa.edu.au Sun Nov 8 15:30:13 2015 Date: Sun Nov 8 15:30:13 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.235.123 Subject: SSTF/SCAN/C-SCAN From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none You are right. It is just 5 marks but when you consider that there were six questions. Each question amounts to 16.67%. I don't think this is necessarily a lesson for us. We did do self reading and learnt on our own but only the topics that were at least mentioned in the lectures. if we were expected to learn the whole book then that's fine, but we should have been told that's what we were expected to do. I love the unit and i absolutely love Chris and his teaching method. Most likely, one of the best teachers that i have had in my life. His enthusiasm and really open approach to the subject truly invites me to learn more about everything he teaches but i also have to say that he is probably one of the worst "lecture note maker" or organizer if he is the one who does that. The lecture notes leave alot to be desired and if they are not going to be of sufficient detail then the book should be required and not just a suggestion. I think, in my opinion, the unit as its own should be much more defined in terms of what is being taught and how everything is structured. From ahmedm07@csse.uwa.edu.au Sun Nov 8 15:34:38 2015 Date: Sun Nov 8 15:34:38 2015 Edit: Sun Nov 8 15:36:18 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.235.123 Subject: SSTF/SCAN/C-SCAN From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none "Daniel Mcfall" <21312007@student.uwa.edu.au> wrote: > With that 1 question being so far out of scope, I think it's just an outlier and > shouldn't be counted. As others have said it's very unreasonable to expect that range of > preparation but I think this was a mistake rather than a lesson that you should do > extensive pre-reading. > > In my eyes outside reading should be done more to gain depth for covered topics, not to > learn topics that weren't covered (unless they're of personal interest). > > Hoping from a reply from Chris! Aside from this question I thought the exam was quite > solid and of similar difficulty to the past paper. Oh. I definitely agree. The exam was very solid except that one question. I loved the fact that some questions were related to the BASH shell project that we did. Everything else was really fair and complex enough to think about it but not that complex that i was going to be banging my head against the table. From graven01@csse.uwa.edu.au Tue Nov 10 14:34:34 2015 Date: Tue Nov 10 14:34:34 2015 To: help2002@csse.uwa.edu.au Received: from 120.16.137.223 Subject: Thank you Chris! From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none Just like to say thank you to Chris for the effort he put into this unit, thoroughly enjoyed it Cheers! From abusha02@csse.uwa.edu.au Tue Nov 10 15:26:12 2015 Date: Tue Nov 10 15:26:12 2015 To: help2002@csse.uwa.edu.au Received: from 203.59.152.130 Subject: Thank you Chris! From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none This has also been my favorite unit so far, personally, thanks in no small part to Chris' teaching style and effort. From mcfald01@csse.uwa.edu.au Tue Nov 10 16:43:30 2015 Date: Tue Nov 10 16:43:30 2015 To: help2002@csse.uwa.edu.au Received: from 10.21.180.155 Subject: Thank you Chris! From: "Daniel Mcfall" <21312007@student.uwa.edu.au> X-smilie: none X-img: none ANONYMOUS wrote: > Just like to say thank you to Chris for the effort he put into this unit, thoroughly > enjoyed it Cheers! Agree completely, loved the teaching style and effort put into help forum From fetzee01@csse.uwa.edu.au Tue Nov 10 16:56:50 2015 Date: Tue Nov 10 16:56:50 2015 Edit: Tue Nov 10 17:28:39 2015 To: help2002@csse.uwa.edu.au Received: from 122.111.255.238 Subject: Thank you Chris! From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none Out of the 9 cits units ive done, apart from cits1401, this was probably the best by far for me, despite it being probably the least "holding your hand one". Maybe when I took those other units, the course structure wasn't as solidified as it is now, but it's been nice to have a lecturer who actually has enthusiasm in teaching. It really helps especially after the disaster that was 2200 last semester. From ahmedm07@csse.uwa.edu.au Tue Nov 10 19:49:40 2015 Date: Tue Nov 10 19:49:40 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.235.123 Subject: Thank you Chris! From: "Maktoom Ahmed" <21728592@student.uwa.edu.au> X-smilie: none X-img: none oh definitely. This course has truly been amazing in terms of content and how Chris's enthusiasm just pulls others in. Its very addictive of sorts. He is an amazing teacher to say the least. However, if there was one thing that i could complain about, it would probably be the fact that his lecture notes are really brief and don't really stand alone on their own. It would be more useful to use the lecture notes at the end of the year without having to listen to the whole lecture. Anyhow, that is a tiny point and Chris deserves all the compliments yet given on this post. Thankyou Again. From bullof01@csse.uwa.edu.au Fri Nov 13 17:06:04 2015 Date: Fri Nov 13 17:06:04 2015 To: help2002@csse.uwa.edu.au Received: from 130.95.252.115 Subject: Marker broke my working project2 code From: "Fraser Bullock" <21299527@student.uwa.edu.au> X-smilie: oops.png X-img: 76dafc42e7902d7c9250cc6b6232bade.png So my final submitted code, although written on linux, was fully tested and working on the Macs in the mac lab. In the feedback though, my code apparently failed executing the basic command trees and pipes. This is not correct. I then saw that I had lost a mark for, and I quote "1 syntactical or logic change made to program to compile or execute (a mark deducted)" How can this be when my submitted code can obviously compile and execute, and then execute correctly? I'm attaching an image of me running and executing the tested commands to this, taken from a mac in the mac lab, using a downloaded copy of the code I submitted. I normally wouldn't complain about this, but I lost 7 marks from this. Is it unfair to ask for a re-mark, or finding out exactly why working code was changed? Thanks Fraser. From graven01@csse.uwa.edu.au Fri Nov 13 18:25:49 2015 Date: Fri Nov 13 18:25:49 2015 To: help2002@csse.uwa.edu.au Received: from 123.2.211.30 Subject: Marker broke my working project2 code From: "Nathan Graves" <21256779@student.uwa.edu.au> X-smilie: none X-img: none "Fraser Bullock" <21299527@student.uwa.edu.au> wrote: > So my final submitted code, although written on linux, was fully tested and working on the > Macs in the mac lab. > > In the feedback though, my code apparently failed executing the basic command trees and > pipes. This is not correct. > > I then saw that I had lost a mark for, and I quote "1 syntactical or logic change made to > program to compile or execute (a mark deducted)" > > How can this be when my submitted code can obviously compile and execute, and then execute > correctly? > > I'm attaching an image of me running and executing the tested commands to this, taken from > a mac in the mac lab, using a downloaded copy of the code I submitted. > > I normally wouldn't complain about this, but I lost 7 marks from this. Is it unfair to ask > for a re-mark, or finding out exactly why working code was changed? > > Thanks > Fraser. Best to email Chris with any such problems, comparing the marking between my project i will note i think i got more harshly marked this time, perhaps due to being a 2nd project. any way still did O.k and learnt a lot. congratulations to those people that got near perfect marks, very impressive. From 00014979@csse.uwa.edu.au Fri Nov 13 18:59:41 2015 Date: Fri Nov 13 18:59:41 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: Marker broke my working project2 code From: "Christopher McDonald" X-smilie: none X-img: none "Fraser Bullock" <21299527@student.uwa.edu.au> wrote: > How can this be when my submitted code can obviously compile and execute, and then execute > correctly? Hello Fraser, It's a case of "yes and no". Unfortunately it appears that different OS-X machines in our School have different/later versions of the C compiler. When tested, seemingly on a machine with a later version, your code produces this compile error: cc -std=c99 -Wall -pedantic -Werror -c searcher.c searcher.c:39:37: error: comparison of array 'paths' not equal to a null pointer is always true [-Werror,-Wtautological-pointer-compare] if(strchr(name, '/') == NULL && paths != NULL){ ^~~~~ ~~~~ 1 error generated. make: *** [searcher.o] Error 1 The error is technically accurate, because your local variable paths is an array, whose address can never change and it is never NULL. To remove the compile error (after trying to understand what your code was trying to do there), I changed your code to just: if(strchr(name, '/') == NULL) { This fixed the compilation error (and that's why you lost a mark for the correction), but then that change has stopped some of the commands/steps from working. SO, please tell me (via email) what you believe that line should be changed to, and I will happily update your mark. > I normally wouldn't complain about this, but I lost 7 marks from this. Is it unfair to ask > for a re-mark, or finding out exactly why working code was changed? It's certainly not unfair to ask for a remark, but most students do so via an email, rather than via the forum! From fetzee01@csse.uwa.edu.au Fri Nov 13 21:42:08 2015 Date: Fri Nov 13 21:42:08 2015 To: help2002@csse.uwa.edu.au Received: from 122.111.255.238 Subject: SSTF/SCAN/C-SCAN From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none any comments about this Chris ? From nelsoj07@csse.uwa.edu.au Sun Nov 15 08:22:39 2015 Date: Sun Nov 15 08:22:39 2015 To: help2002@csse.uwa.edu.au Received: from 203.59.202.30 Subject: Next steps From: "Jake Nelson" <20752958@student.uwa.edu.au> X-smilie: sorcerer.png X-img: none Heya to anyone still checking the forums! I'm pretty keen to keep learning more and looking for some projects to start over the break. I'm going to have a decent amount of spare time at points, and wondering what everyone would recommend. So far the thoughts / options that I have are: - following a textbook or two - trying to find some basic projects online to implement in C / Java - learning more about Linux - learning more about Git - learning some Python ( haven't done the first year course and may do so next year ) Any good options that I've missed, basically trying to brainstorm here! If anyone has any suggestions to make any of the options more specific, like a certain book or certain project I'd love to hear it! Thanks From abusha02@csse.uwa.edu.au Sun Nov 15 18:33:56 2015 Date: Sun Nov 15 18:33:56 2015 To: help2002@csse.uwa.edu.au Received: from 106.68.43.213 Subject: Next steps From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: 883ae8b327ed1165c1995c959c8b7408.pdf Let's see. If you're after books, the 'Core Java' books are very thorough books that cover Java to a magnificent extent. They are behemoths of books, so they won't be short reads, but it'll probably cover a lot of ground that you've yet to tread, especially the 2nd volume, which covers advanced features. Unless you're after coverage on a specific topic, that's really the best recommendation I can give for Java (you'll see why if you take a look at them). As for C, there are books like C Primer Plus, but if you've gone through this unit properly, most of that's going to be familiar to you. The only new stuff will be found in the last few chapters, and those are mostly bridges between C and 2200 (data structures & algorithms), so if you've done 2200, 'C Primer Plus' might not be worth the read at this point. If you're after more advanced stuff, 'Algorithms in C' by Sedgewick are pretty good books, but you will again find lots of familiar territory if you've studied 2200. In this case, though, I'd still call them a worthy read, as they will still cover lots of new territory, and in you're a comp. science student, solidifying your 2200 knowledge is pretty vital (especially if you're taking 3001 next year). Now, let me backpedal a little what I just said. 'Algorithms in C' is good, but 'Algorithms (Fourth Edition)' by Sedgewick is even better (and much more recent). 'Algorithms' is instead covered in Java, but there isn't much difference; really the task with these books is to learn the algorithms, not to learn their implementations in a specific language. If you know the languages well enough, and understand the algorithms (as opposed to rote-learning the code), you shouldn't have trouble translating them to whatever language is needed. There is also 'Essential Algorithms' published by Wiley, which is quite good (and uses pseudo-code for all examples); the coverage between that and Sedgewick's book isn't anything approaching a 1:1 match, so it's your choice which you go after (or whether you just read intriguing chapters/sections from each etc.). I have heard a lot of praise for the 'Effective Java' book, but I haven't read that myself, so I can't affirm or deny such praise. You could look into it. Of course, my last recommendation as far as books go would be to read the 'OS: Internals and Design Principles' book, or any other OS book, in full, if you're interested in the topic. Not sure about you, but I only covered about 5 chapters of it while revising for this unit (most other stuff was beyond the scope), and it seems like it'd be interesting to read the rest. As far as projects go, most of these books provide end of chapter exercises and the like, and in the later chapters, these can get quite large. The aforementioned OS book does actually provide (within the online resources, I believe) 2 projects for the students to carry out. One of the 2, though, is almost identical to our 2nd project, so you might not find much point in doing that. As far as projects go: https://www.reddit.com/r/learnprogramming/comments/2a9ygh/1000_beginner_programming_projects_xpost/ That link is to a thread that aims to compile lots of different coding exercises and projects for people to undertake. Maybe you'll find what you're looking for there. I can at least get you started on something, though. There should be a PDF attached to this comment. It is a project you might find fun and interesting to tackle. It says 'any language,' but it should be pretty obvious that an Object Oriented language is the best way to approach it (you might be most comfortable with Java, at this stage). It shouldn't be too difficult, but you might need to learn some new stuff while completing it (depending on your experience). Especially if you've done 2200, you shouldn't have too much trouble with it (I just say that because 2200 is a hard unit to 'wing', and demands a working knowledge of Java and OOP principles from its students, whereas units like 1001 can be completed successfully by students who just rote-learn some code, and don't actually have a working understanding of anything to do with programming; this was the case with myself, actually, and 2200 is what forced me to properly learn the principles I'd neglected to care about in 1001). You can find all the books on Amazon, or I'm sure you can pretty easily get your hands on digital copies of them by sailing the high seas of the net (most of them are pretty easily found, other than the OS ones; personal experience). Have fun. From abusha02@csse.uwa.edu.au Sun Nov 15 18:41:13 2015 Date: Sun Nov 15 18:41:13 2015 Edit: Sun Nov 15 18:43:05 2015 To: help2002@csse.uwa.edu.au Received: from 106.68.43.213 Subject: Next steps From: "Ammar Abu Shamleh" <21521274@student.uwa.edu.au> X-smilie: none X-img: none It doesn't seem like you can attach a PDF to a post on this help forum. Here you go: http://www.mediafire.com/download/zhwify86fn04x4a/AgileScrumTaskBoard.pdf You can download that project I was talking about earlier from mediafire. (Ignore the 'submission' stuff at the bottom). From lopasb03@csse.uwa.edu.au Mon Nov 16 07:17:49 2015 Date: Mon Nov 16 07:17:49 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.199.116 Subject: Next steps From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: bigsmile.png X-img: none [Message removed] From fletca07@csse.uwa.edu.au Mon Nov 16 12:35:18 2015 Date: Mon Nov 16 12:35:18 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.171.197 Subject: Next steps From: "Alexander Fletcher" <21501626@student.uwa.edu.au> X-smilie: angry.png X-img: none Rocko represent in all seriousness the resources listed above are pretty good. Some of those beginner projects are a bit much for example one of them goes from reversing a string to creating a WYSIWYG Web editor. I have the head first Java book which is actually really good. For python codeacademy is a pretty good place to start and for me i started using api's and messing around (in particular the Riot Api for league of legends) as python can be used as a back end for a website and so this was good practice in python and in api's / JSON objects. From lopasb03@csse.uwa.edu.au Mon Nov 16 13:08:42 2015 Date: Mon Nov 16 13:08:42 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.199.116 Subject: Next steps From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-img: none [message removed] From fetzee01@csse.uwa.edu.au Mon Nov 16 17:44:32 2015 Date: Mon Nov 16 17:44:32 2015 To: help2002@csse.uwa.edu.au Received: from 122.111.255.238 Subject: SSTF/SCAN/C-SCAN From: "Elijah Fetzer" <21516694@student.uwa.edu.au> X-smilie: none X-img: none apparently not, maybe this has happened in previous exams, as I was speaking to someone who did the unit before From 00014979@csse.uwa.edu.au Tue Nov 17 17:38:46 2015 Date: Tue Nov 17 17:38:46 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: SSTF/SCAN/C-SCAN From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > any comments about this Chris ? Please check your UWA email. From 00014979@csse.uwa.edu.au Tue Nov 17 17:40:22 2015 Date: Tue Nov 17 17:40:22 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: SSTF/SCAN/C-SCAN From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > apparently not, maybe this has happened in previous exams, as I was speaking to > someone who did the unit before Your friend seems mistaken; I have all past years' lecture notes and final exams if they'd like to check. From 00014979@csse.uwa.edu.au Tue Nov 17 17:43:14 2015 Date: Tue Nov 17 17:43:14 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: Next steps From: "Christopher McDonald" X-smilie: none X-img: none "Jake Nelson" <20752958@student.uwa.edu.au> wrote: > I'm pretty keen to keep learning more and looking for some projects to start over the > break. I'm going to have a decent amount of spare time at points, and wondering what > everyone would recommend. If you have plenty of spare time to kill, and want to make it productive, you may be interested in some of the internships and 2016 scholarships announced on: https://secure.csse.uwa.edu.au/run/csforum From 00014979@csse.uwa.edu.au Tue Nov 17 17:47:36 2015 Date: Tue Nov 17 17:47:36 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: Syntax Leniency in code questions From: "Christopher McDonald" X-smilie: none X-img: none ANONYMOUS wrote: > Regarding mistakes such as the following: > instead of execv I accidently wrote execl ! So, one letter, even though I understood the > question fully. This mistake would’ve made the program not compile but if I said execv > instead, it would work perfectly. No; there's no loss of marks for such a simple (let's call it a) typo. It's exactly the sort of thing that you've have looked up if you had access to online resources. BTW - that's not a syntactic error (which would involve the keywords, punctuation, control-flow of the language); it's just the wrong choice of function (by its name). From lopasb03@csse.uwa.edu.au Tue Nov 17 19:06:47 2015 Date: Tue Nov 17 19:06:47 2015 To: help2002@csse.uwa.edu.au Received: from 101.186.199.116 Subject: Syntax Leniency in code questions From: "Benjamin Lopas" <19922921@student.uwa.edu.au> X-smilie: thumbup.png X-img: none Nice, thanks Christopher, that should help my mark a little bit. c",) From 00014979@csse.uwa.edu.au Sat Nov 21 09:35:54 2015 Date: Sat Nov 21 09:35:54 2015 To: help2002@csse.uwa.edu.au Received: from 106.69.250.242 Subject: Happy 30th birthday Windows! From: "Christopher McDonald" X-smilie: party.png X-img: none A visual history: http://www.theverge.com/2015/11/19/9759874/microsoft-windows-visual-history-30-years