Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        3年前关闭。
                                                                                            
                
        
我想知道为什么我在这里使用%2s:

char card_name[3];
puts ("Enter the card name: ");
scanf ("%2s, card_name);


以及为什么我使用%2d:

int n = 0;
scanf ("%2d", &n);
printf ("-> %d\n", n);

最佳答案

您选择了%2s格式说明符,因为您希望读取a string of size 2%2d来输出a two digit decimal number

有关更多详细信息,请参见documentation of scanf

10-06 11:45