whitespace in the format string (scanf)

前端 未结 4 1955
日久生厌
日久生厌 2020-12-05 12:23

Consider the following code:

#include
int main() {
    int i=3, j=4;
    scanf(\"%d c %d\",&i,&j);
    printf(\"%d %d\",i,j);
    retu         


        
4条回答
  •  伪装坚强ぢ
    2020-12-05 12:53

    I think I would read the scanf result into different variables (i.e. not reuse i and j) as "%d%s%d". Then check the string you got from the %s and if it matches your requirements, use the other variables to overwrite i and j.

提交回复
热议问题