Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two Questions #16

Closed
DanTheTingler opened this issue Aug 2, 2014 · 7 comments
Closed

Two Questions #16

DanTheTingler opened this issue Aug 2, 2014 · 7 comments

Comments

@DanTheTingler
Copy link
Contributor

Hey everybody,

I have two questions:

  1. Does anyone know how to properly use read?

This statement here is giving me compiler errors:

if(read(fd, "README", 6) == -1)
{
    perror("read failed");
    exit(1);
}

This is the compiler error I'm getting:

main.cpp:33:28: error: invalid conversion from ‘const void_’ to ‘void_’ [-fpermissive]
if(read(fd, "README", 6) == -1)
^
In file included from main.cpp:5:0:
/usr/include/unistd.h:360:16: error: initializing argument 2 of ‘ssize_t read(int, void*, size_t)’ [-fpermissive]
extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur;

  1. Second, does anyone know how I can update my git folder to sync with the ucr-cs100 one on github? I tried 'git fetch upstream' but it says I don't have correct access rights. I'm still very shaky with how to use git, so sorry!

Thanks!

@bmars003
Copy link
Collaborator

bmars003 commented Aug 2, 2014

To answer your first question, I believe that you are using the read() function incorrectly. The error is with your second argument to the read() function, you pass in "README", but when you look at the error that you get you can notice that the second argument is supposed to be along the lines of void *__buf.This argument is the buffer where the read data is stored.

@DanTheTingler
Copy link
Contributor Author

Okay, so what would be an example of the correct way to use the read function? Not too sure what a void *_buf is. Thanks Bryan!

@aguerrero
Copy link
Contributor

To sync with upstream you can run the following commands:

git remote add upstream https://github.com/mikeizbicki/ucr-cs100.git
git fetch upstream
git checkout master
git merge upstream/master

@bmars003
Copy link
Collaborator

bmars003 commented Aug 2, 2014

@aguerrero thanks for the post
@DanTheTingler
Take a look at these.

  1. http://www.tutorialspoint.com/unix_system_calls/read.htm
  2. http://www.cs.uregina.ca/Links/class-info/330/SystemCall_IO/SystemCall_IO.html

As a side not, as a programmer being able to look up information is a variable skill.

@mikeizbicki
Copy link
Owner

These are good answers, but I'd like to add the following:

  1. The read function is NOT necessary for the assignment. You certainly CAN use it to get user input, but you do not HAVE TO use it. We haven't actually talked about it in class yet. I personally recommend you use cin and getline in iostream.
  2. For the homework, make sure you've created a NEW project on github called rshell. You should NOT be recreating it under the ucr-cs100 project.

@DanTheTingler
Copy link
Contributor Author

Thanks for the answers Mike! I'm still unfamiliar with how to use github, so if it's not too much trouble, can you outline the steps of creating a new project and syncing it with our computers? Would it be just like the lab? Thanks!

@mikeizbicki
Copy link
Owner

Go to http://github.com. On the right hand side there's a button labeled new repository. Click that button. It'll ask you some basic question about your new repository, like the name. There'll be some instructions for how to clone the repo onto your computer, but the basic idea will be just like in lab.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants