How do you read the line through the scanf?



  • I'm putting the line through the index.

    int main(){
        char *s;
        scanf("%s", &s);
        printf("%s", s);
    }
    

  • QA Engineer

    We need to celebrate where to read. ♪ ♪

    char * s = malloc(1024); // Или сколько вам надо
    scanf("%s",s);      // Чтение ОДНОГО СЛОВА
    scanf("%[^\n]",s);  // Чтение строки до конца (символа новой строки)
    


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2