c语言:编一程序从键盘输入一串字符"may friendship pptforever! ",然后保存在文件myInfo.txt中

C语言填空题: 从键盘输入一串字符,将其保存到文本文件f1.txt中。_百度知道
C语言填空题: 从键盘输入一串字符,将其保存到文本文件f1.txt中。
&stdio.h& #include
&stdlib.h& void main( ) {
char str[100];
/* 打文件 */
printf ( &File open error!\n& );
printf( &输入字符串:& );
gets(str);
/* 写文件 */
if( fclose(fp) ) {
printf( &Can not close the file!\n& );
提问者采纳
斐波契数列 1 1 2 3 5 8 13 21 34~~~~我猜f1f2初始值都1吧我假设要求数length=20;f=f1+f2=2 (f第三数)要求第四数f1=f2f2=f;f=f1+f2=3 (f第四数)要求第五数f1=f2f2=f;f=f1+f2=5 (f第五数)类推希望帮助
其他类似问题
为您推荐:
其他2条回答
基础题目何手做遍呢手才能记忆犹新呀
NULL==(fp=fopen(&f1.txt&,&wt&))fp,str
键盘输入的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁C语言编程题:从键盘输入一串字符,统计其中的数字与字母个数并输出。(用指针实现)_百度知道
C语言编程题:从键盘输入一串字符,统计其中的数字与字母个数并输出。(用指针实现)
提问者采纳
#include &stdio.h&#define N 200void count(char *);int main(){
ch=malloc(N+1);
printf(&请输入输入行字符:\n&);
count(ch);
getchar();} void count(char *ch){
char *temp=
int i, chr=0,digit=0;
while(*ch != '\0')
if((*ch&='A' && *ch&='Z') ||(*ch&='a' && *ch&='z') )
else if (*ch&='0' && *ch&='9')
{digit++;}
printf(&该字符串字母%d数字:%d\n&,chr,digit);}
提问者评价
其他类似问题
为您推荐:
其他3条回答
#include &stdio.h&int main(){
int n, t, n1=0, n2=0;
char str[1001], *p;
printf(&请输入字符串: &);
gets(str);
while (*p!='\0') {
if(*p&='0' && *p&='9') n1 ++;
else if (*p&='a' && *p&='z' || *p&='A' && *p&='Z') n2 ++;
printf(&其数字%d, 字母%d\n&,n1, n2);
return 0;}
#include&stdio.h&#include&string.h&void main(){
char ch[128];
int alpha = 0, num = 0, spc = 0, oth = 0;
int i = 0;
printf(&请输入字符串: &);
while ((ch[i++] = getchar()) != '\n');
for (i = 0; i & strlen(ch); i++)
if ((ch[i] &= 'a' && ch[i] &= 'z') || (ch[i] &= 'A' && ch[i] &= 'Z'))
else if (ch[i] &= '0' && ch[i] &= '9') num++;
else if (ch[i] == 32) spc++;
else oth++;
printf(&字母: %d, 数字: %d, 空格: %d, 其他: %d\n&, alpha, num, spc, oth);}
#include&stdio.h&int main(){int word=0,number=0,gap=0,other=0;while((c=getchar())!='\n'){if(c&='A'&&c&='Z'||c&='a'&&c&='z')word++; else if(c&='0'&&c&='9')number++;else if(c==' ')gap++;elseother++;}printf(&word:%d\tnumber:%d\tgap:%d\tother:%d\n&,word,number,gap,other);return 0;}
c语言编程的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁C语言中 先从键盘上获取一串字符串 再将字符串内的每个字符都转换为ASCII码格式_百度知道
C语言中 先从键盘上获取一串字符串 再将字符串内的每个字符都转换为ASCII码格式
我想写段程序让先键盘获取串字符串ASCII码输要保持每单字符ASCII码间空格(便于区每字符ASCII码)并源码转换内容输文件(主要希望能字符串字符逐翻译ASCII码)请问程序应该编写
提问者采纳
#include&stdio.h&#include&conio.h&int main(void){ char a[10]; gets(a); for(i=0;i&10;i++) printf(&%d &,a[i]); getch(); return 0;} 知道意思
相关专业回答
将字符转换为整型自动将字符ASCALL值取出 char a='a'; i=a;
其他类似问题
为您推荐:
其他2条回答
输入字符串 于百说/* Note:Your choice is C IDE */#include &stdio.h&#include &string.h&void main(){
char a[100];int n,i; gets(a);puts(a);
n=strlen(a);
for(i=0;i&n;i++)
printf(&%4d&,a[i]);
}要注意字符整型相通
呵呵 觉知道要输入串应该/* Note:Your choice is C IDE */#include &stdio.h&#include &string.h&void main(){
int n,i;char a,*p=&a; gets(p);
n=strlen(p);
for(i=0;i&n;i++)
printf(&%4d&,*p+i);
我写了段代码,你的要求都满足了,VS2005上运行通过了,你可以试试
#include &stdio.h&
#include &string.h&
#include &stdlib.h&
#define MAX_STRING 100
int main()
char arr[MAX_STRING];
if(fp = fopen(&text.txt&,&w&))
printf(&Please input:&);
scanf(&%s&,&arr);
number = strlen(&arr);
for(i=0;i&i++)
printf(&%d &,arr[i]);
for(i=0;i&i++)
fwrite(&arr[i],sizeof(char),1,fp);
fwrite(&:&,sizeof(char),1,fp);
asc = arr[i];
fprintf(fp, &%d\n&, asc);
printf(&Can not open file!\n&);
fclose(fp);
getchar(...
ascii码的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁中国石油大学C语言答案_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
中国石油大学C语言答案
上传于||暂无简介
阅读已结束,如果下载本文需要使用
想免费下载本文?
下载文档到电脑,查找使用更方便
还剩71页未读,继续阅读
你可能喜欢C语言编程题:从键盘输入一串字符,统计其中的数字与字母个数并输出。(用指针实现)_百度知道
C语言编程题:从键盘输入一串字符,统计其中的数字与字母个数并输出。(用指针实现)
提问者采纳
#include &stdio.h&#define N 200void count(char *);int main(){
ch=malloc(N+1);
printf(&请输入输入行字符:\n&);
count(ch);
getchar();} void count(char *ch){
char *temp=
int i, chr=0,digit=0;
while(*ch != '\0')
if((*ch&='A' && *ch&='Z') ||(*ch&='a' && *ch&='z') )
else if (*ch&='0' && *ch&='9')
{digit++;}
printf(&该字符串字母%d数字:%d\n&,chr,digit);}
提问者评价
其他类似问题
为您推荐:
其他3条回答
#include &stdio.h&int main(){
int n, t, n1=0, n2=0;
char str[1001], *p;
printf(&请输入字符串: &);
gets(str);
while (*p!='\0') {
if(*p&='0' && *p&='9') n1 ++;
else if (*p&='a' && *p&='z' || *p&='A' && *p&='Z') n2 ++;
printf(&其数字%d, 字母%d\n&,n1, n2);
return 0;}
#include&stdio.h&#include&string.h&void main(){
char ch[128];
int alpha = 0, num = 0, spc = 0, oth = 0;
int i = 0;
printf(&请输入字符串: &);
while ((ch[i++] = getchar()) != '\n');
for (i = 0; i & strlen(ch); i++)
if ((ch[i] &= 'a' && ch[i] &= 'z') || (ch[i] &= 'A' && ch[i] &= 'Z'))
else if (ch[i] &= '0' && ch[i] &= '9') num++;
else if (ch[i] == 32) spc++;
else oth++;
printf(&字母: %d, 数字: %d, 空格: %d, 其他: %d\n&, alpha, num, spc, oth);}
#include&stdio.h&int main(){int word=0,number=0,gap=0,other=0;while((c=getchar())!='\n'){if(c&='A'&&c&='Z'||c&='a'&&c&='z')word++; else if(c&='0'&&c&='9')number++;else if(c==' ')gap++;elseother++;}printf(&word:%d\tnumber:%d\tgap:%d\tother:%d\n&,word,number,gap,other);return 0;}
c语言编程的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁

我要回帖

更多关于 friendship ppt 的文章

 

随机推荐