例如,当输入为25时,输出必须为7(数字12345678910111213141516171819202122232425的第25位)
如何在C中解决此问题?
在运行此代码时,我得到一个浮点异常.
为什么zero divison error没有打印文字?它应该被打印,因为在除零之前printf("zero divison error")执行了零.
#include<stdio.h>
int main()
{
int p=0;int a=2;
printf("zero divison error");
printf("%d",a/p);
// why zero divison error is not printed?
// i am getting floating point exception(core dumped).
}
Run Code Online (Sandbox Code Playgroud) 我需要从示例 MPEG-TS 文件中获取 PIDS,我尝试使用读取文件fopen()并以十六进制格式获取数据。现在我一直在寻找整个数据中的 PID 字节。谁能帮我吗?
我使用了以下代码:
#include <stdio.h>
#include <string.h>
void main()
{
FILE *myfile;
FILE *output;
int i=0,j;
unsigned int buffer;
int o;
myfile=fopen("screen.ts","rb");
output = fopen("output2.txt","w");
do{
o=fread(&buffer, 2, 1, myfile);
if(o!=1)
break;
printf("%d: ",i);
printf("%x\n",buffer);
fprintf(output,"%x ",buffer);
i++;
}while(1);
}
Run Code Online (Sandbox Code Playgroud)
我从文件中获取了数据,现在我需要找到数据中的“PID”字节。
我正在学习c pragramming,当我尝试在引文中打印"Hello World"时,我收到一个错误:
id返回1退出状态
这是我的代码,我正在使用codeblock:
#include <stdio.h>
int main()
{
printf("\"Hello World\" ");
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我知道在指令结束时我需要分号,但是当我尝试编译时,它会在我不知道原因的地方问我分号并且它有效但现在的问题是为什么我在开头需要分号一段时间循环和结束括号之前?
#include <unistd.h>
int main()
{
char a = 'a'
;while (a <= 'z')
{
write(1, &a, 1);
a++;
}
return (0)
;}
Run Code Online (Sandbox Code Playgroud)
但我在这段代码中不需要分号(至少在此之前)
#include <unistd.h>
char ft_putchar(char c)
{
write(1, &c, 1);
}
char rec(char a)
{
if (a <= 'z')
{
ft_putchar(a);
a++;
rec(a);
}
return (0);
}
int main()
{
char a = 'a';
rec(a);
return (0);
}
Run Code Online (Sandbox Code Playgroud)
我在Windows 10视觉工作室代码上运行.