Skip to main content
deleted 4 characters in body
Source Link
dudeofea
  • 340
  • 5
  • 21

2 things to say:

  1. It looks nicer when you use one format string
  2. You should use a loop

Here's some code:

int a,b,c;
char str[256];
while(fscanf(fd, "%d %d %d %s ", &a, &b, &c, &str[0]str) == 4){
    //get some coffee
}

this is a standard while not End of File loop. Also, str doesn't need & because it already is a pointer and doesn't need to be referenced like a, b or c. The space at the end of the format string, after %s, means it will stop once that one space is read. This way it is not included in the string str.

2 things to say:

  1. It looks nicer when you use one format string
  2. You should use a loop

Here's some code:

int a,b,c;
char str[256];
while(fscanf(fd, "%d %d %d %s ", &a, &b, &c, &str[0]) == 4){
    //get some coffee
}

this is a standard while not End of File loop. Also, str doesn't need & because it already is a pointer and doesn't need to be referenced like a, b or c. The space at the end of the format string, after %s, means it will stop once that one space is read. This way it is not included in the string str.

2 things to say:

  1. It looks nicer when you use one format string
  2. You should use a loop

Here's some code:

int a,b,c;
char str[256];
while(fscanf(fd, "%d %d %d %s ", &a, &b, &c, str) == 4){
    //get some coffee
}

this is a standard while not End of File loop. Also, str doesn't need & because it already is a pointer and doesn't need to be referenced like a, b or c. The space at the end of the format string, after %s, means it will stop once that one space is read. This way it is not included in the string str.

deleted 2 characters in body
Source Link
dudeofea
  • 340
  • 5
  • 21

2 things to say:

  1. It looks nicer when you use one format string
  2. You should use a loop

Here's some code:

int a,b,c;
char str[256];
while(fscanf(fd, "%d %d %d %s ", &a, &b, &c, &str[0]) !=== EOF4){
    //get some coffee
}

this is a standard while not End of File loop. Also, str doesn't need & because it already is a pointer and doesn't need to be referenced like a, b or c. The space at the end of the format string, after %s, means it will stop once that one space is read. This way it is not included in the string str.

2 things to say:

  1. It looks nicer when you use one format string
  2. You should use a loop

Here's some code:

int a,b,c;
char str[256];
while(fscanf(fd, "%d %d %d %s ", &a, &b, &c, &str[0]) != EOF){
    //get some coffee
}

this is a standard while not End of File loop. Also, str doesn't need & because it already is a pointer and doesn't need to be referenced like a, b or c. The space at the end of the format string, after %s, means it will stop once that one space is read. This way it is not included in the string str.

2 things to say:

  1. It looks nicer when you use one format string
  2. You should use a loop

Here's some code:

int a,b,c;
char str[256];
while(fscanf(fd, "%d %d %d %s ", &a, &b, &c, &str[0]) == 4){
    //get some coffee
}

this is a standard while not End of File loop. Also, str doesn't need & because it already is a pointer and doesn't need to be referenced like a, b or c. The space at the end of the format string, after %s, means it will stop once that one space is read. This way it is not included in the string str.

added 8 characters in body
Source Link
dudeofea
  • 340
  • 5
  • 21

2 things to say:

  1. It looks nicer when you use one format string
  2. You should use a loop

Here's some code:

int a,b,c;
char *str;str[256];
while(fscanf(fd, "%d %d %d %s ", &a, &b, &c, str&str[0]) != EOF){
    //get some coffee
}

this is a standard while not End of File loop. Also, str doesn't need & because it already is a pointer and doesn't need to be referenced like a, b or c. The space at the end of the format string, after %s, means it will stop once that one space is read. This way it is not included in the string str.

2 things to say:

  1. It looks nicer when you use one format string
  2. You should use a loop

Here's some code:

int a,b,c;
char *str;
while(fscanf(fd, "%d %d %d %s ", &a, &b, &c, str) != EOF){
    //get some coffee
}

this is a standard while not End of File loop. Also, str doesn't need & because it already is a pointer and doesn't need to be referenced like a, b or c. The space at the end of the format string, after %s, means it will stop once that one space is read. This way it is not included in the string str.

2 things to say:

  1. It looks nicer when you use one format string
  2. You should use a loop

Here's some code:

int a,b,c;
char str[256];
while(fscanf(fd, "%d %d %d %s ", &a, &b, &c, &str[0]) != EOF){
    //get some coffee
}

this is a standard while not End of File loop. Also, str doesn't need & because it already is a pointer and doesn't need to be referenced like a, b or c. The space at the end of the format string, after %s, means it will stop once that one space is read. This way it is not included in the string str.

Source Link
dudeofea
  • 340
  • 5
  • 21
Loading