我想知道GCC的编译时间.GCC是否有任何计算编译时间的命令或选项?
我有一个名为hello.c的文件,并将编译它.我想知道编译它所花费的时间.
我记得我在某个地方(可能是在Github)看到了这样一个例子:
void MyClass::setValue(int newValue)
{
if (value != newValue) {
value = newValue;
}
}
Run Code Online (Sandbox Code Playgroud)
对我而言,它没有多大意义,但我想知道它是否会带来任何性能提升.
所以我的兄弟正在制作一个程序,将字符串中的所有单词转换为主题标签,但由于某种原因,它总是在执行结束时出现"分段错误"错误.我试图找到可能导致它的原因,但还没有找到.这是代码:
#include <stdio.h>
#include <string.h>
char* setHashtag(char text[10000])
{
int i, j;
printf("Initial text = %s\n", text);
for (i = 9998; i >= 0; i--)
{
text[i+1] = text[i];
}
text[0] = ' ';
for (i = 0; text[i+1] != '\0'; i++)
{
if(text[i] == ' ' && text[i+1] != ' ')
{
for (j = 9998; j > i; j--)
{
text[j+1] = text[j];
}
text[i+1] = '#';
printf("Partial text = %s\n", text);
}
}
return text;
}
void …Run Code Online (Sandbox Code Playgroud)