Question: I have to write a program that takes a file name from the command line.
It then read several bytes from the file, looking for strings of printable characters (ASCII values between `32` and `126` decimal).
Then print out the strings.
A string is a run of at least `4` consecutive printable characters and ends whenever a non-printable character is encountered.
Whenever such a string is found, print it out on a new line.

What I have so far is:

```
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]){
    FILE *fp;
    fp = fopen(argv[1], "rb");
    char buffer;

    while(fp != NULL)
    {
        fread(&buffer, 1, 1, fp);
    }

    fclose(fp);
}

```

What I think this does it take the program from the command line and read in all the bytes of the file 1 by 1 and store them into `buffer`.
Now I need to check each part of the array and see if each element is between `32` and `136`.
If it is, I add those bytes to another array until there is a byte not in this range.
Do this for the entirety of the `buffer` array.
Is this a code approach and is this right so far?

Answer: 
First thing define your `context` inside your `onCreateView` method.

```
final Context context;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.activity,
            container, false);
      context = getActivity();

```
Use bellow way 

```
RegisterAsync extends AsyncTask<String, Void, AsyncTaskResult<JSONObject>> {

    ProgressDialog dlg;

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        dlg = new ProgressDialog(context); 
        dlg.setCanceledOnTouchOutside(false);
        dlg.setCancelable(false);      
        dlg.setMessage("Please wait...."); 
        dlg.show();
    }

    @Override
    protected AsyncTaskResult<JSONObject> doInBackground(String... params) {
        //do your stuff
    }

    protected void onPostExecute(AsyncTaskResult<JSONObject>  result) {
            }

```