我有一个prinf函数列表,我想知道如何遍历它们。
#include <stdio.h>
void N()
{
int count;
count += count;
}
int main()
{
int pfReturnCount = 0;
pfReturnCount = printf("#####.00000000000.......00000...00000#### \n");
pfReturnCount = printf("#####..000.....000......000000...000.#### \n");
pfReturnCount = printf("#####..000.....000......000.000..000.#### \n");
pfReturnCount = printf("#####..0000000000.......000..000.000.#### \n");
pfReturnCount = printf("#####..000.....000......000...000000.#### \n");
pfReturnCount = printf("#####..000.....000......000....00000.#### \n");
pfReturnCount = printf("#####.00000000000......00000...00000.#### \n");
N(pfReturnCount);
printf("data value after calling the N funtion is %d\n",pfReturnCount);
return (0);
}
我得到它给我第一个printf的值,但我不知道如何遍历整个列表,所以我可以总结我在所有printf函数中的字符总数。
答案 0 :(得分:0)
只需用+ =
替换=#include <stdio.h>
void N()
{
int count;
count += count;
}
int main()
{
int pfReturnCount = 0;
pfReturnCount += printf("#####.00000000000.......00000...00000#### \n");
pfReturnCount += printf("#####..000.....000......000000...000.#### \n");
pfReturnCount += printf("#####..000.....000......000.000..000.#### \n");
pfReturnCount += printf("#####..0000000000.......000..000.000.#### \n");
pfReturnCount += printf("#####..000.....000......000...000000.#### \n");
pfReturnCount += printf("#####..000.....000......000....00000.#### \n");
pfReturnCount += printf("#####.00000000000......00000...00000.#### \n");
N(pfReturnCount);
printf("data value after calling the N funtion is %d\n",pfReturnCount);
return (0);
}
答案 1 :(得分:0)
您可以将每一行推送到一个字符串数组,然后只需获取数组中每个元素的长度。