[英]Is it possible to input a variable of some sort and compare it with another variable at the same time in C?
I was wondering if there was possibly a way where one could scan a variable and then compare it all in the same line (same time). 我想知道是否可能有一种方法可以扫描一个变量,然后将它们全部在同一行(同一时间)进行比较。
So far I tried this: 到目前为止我试过这个:
if(strcmp((scanf("create.%s",comp)),comp)==0) //Please do not mind any missed parentheses or something like that...
I know ^that doesn't work because I've tried it and it ended up with an error... 我知道^那不起作用,因为我已经尝试过了,结果却出现了错误......
So how would one achieve such a task? 那么如何实现这样的任务呢? Or is it impossible?
还是不可能?
If you really really want to do that (and I see no reason to), you may do the following: 如果你真的想这样做(我没有理由),你可以做以下事情:
char *superScanfWithString(const char *format, char * str) { scanf(format,str); return str; } ... if(strcmp((superScanfWithString("create.%s",comp)),comp)==0)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.