编写一个 C 程序来处理使用函数和循环的语句!
问题
C语言程序中如何根据指定的长度将长行打印成两条或多条短行?
解决方案
让我们编写一个代码来读取一个长行并根据程序中提到的大小打印成两个或多个短行。
我们在这个程序readline()函数中使用的内置函数用于将文本存储在数组中并返回行的大小。
我们用来阅读短句的逻辑解释如下-
while((charcter=readtext())>0){ if(charcter>length){ count=0; a=0; while(a我们用来阅读长句的逻辑解释如下-
for(i=0;i程序
以下是使用函数和循环处理语句的C程序-
#include#define MAX 100 int readtext(void); char msg[MAX]; const int length=30; int main(){ int a,b,count,charcter; printf("enter the statement:\n"); while((charcter=readtext())>0){ if(charcter>length){ count=0; a=0; while(a 输出结果 输出如下-
enter the statement: Hi Welcome to nhooo .It is one of the biggest platform where you can find all types of study materials with a very good and validate content,students can get there solutions in this platform Hi Welcome to nhooo .It is one of the biggest platform where you can find all types of study materials with a very good and validate content,students can get there solutions in this platform