所以(只是为了好玩),我只是想编写一个C代码来复制文件.我四处看看似乎从流调用中读取的所有函数fgetc()(我希望这是真的吗?),所以我使用了这个函数:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define FILEr "img1.png"
#define FILEw "img2.png"
main()
{
clock_t start,diff;
int msec;
FILE *fr,*fw;
fr=fopen(FILEr,"r");
fw=fopen(FILEw,"w");
start=clock();
while((!feof(fr)))
fputc(fgetc(fr),fw);
diff=clock()-start;
msec=diff*1000/CLOCKS_PER_SEC;
printf("Time taken %d seconds %d milliseconds\n", msec/1000, msec%1000);
fclose(fr);
fclose(fw);
}
Run Code Online (Sandbox Code Playgroud)
在2.10Ghz core2Duo T6500 Dell inspiron笔记本电脑上,这个文件的运行时间为140毫秒.但是,当我尝试使用fread/时fwrite,我会减少运行时间,因为我不断增加st为每个调用传输的字节数(即以下代码中的变量),直到它在10ms左右达到峰值!这是代码:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define FILEr "img1.png"
#define FILEw "img2.png"
main()
{
clock_t start,diff;
// number of bytes copied at each step
size_t st=10000; …Run Code Online (Sandbox Code Playgroud) 它总是在工作中发生,某人不小心将某件事提交给了主人,而不是交给了预期的功能分支,然后该人尝试解决该问题,只是使更改突然消失。我搜索了很多东西,找不到文档说明这种情况的发生原因或解决方法。
以下是重现步骤:
$ git init
$ echo hello world > testfile
$ git add testfile
$ git commit -m 'init'
$ git branch A
$ echo abc >> testfile
$ git commit -am 'append abc'
$ git revert HEAD --no-edit
$ git checkout A
$ echo fff > secondfile
$ git add secondfile
$ git commit -m 'Add second file'
$ git cherry-pick master^
Run Code Online (Sandbox Code Playgroud)
此时,git历史记录如下所示:
$ git log --oneline --all --graph --decorate
* ac6f9b4 (HEAD -> A) append abc
* …Run Code Online (Sandbox Code Playgroud) 如果这是重复的道歉...希望不是.我搜索了一长串问题,但他们似乎并没有真正解释它.
这里是:在下面
int main(int,char**){
auto a = make_unique<std::string>("Hello World");
// do stuff with either &*a or a.get()
return 0;
}
Run Code Online (Sandbox Code Playgroud)
&*a和之间有什么区别a.get()?我知道他们都返回原始指针值(除非operator&是重载),但是选择一个优于另一个有任何运行时优势吗?
我在teuton.blogspot.com上按照指南设置自动完成功能,当我运行命令时:
ctags –R --c++-kinds=+p --fields=+iaS --extra=+q \
-f ~/.vim/commontags /usr/includeRun Code Online (Sandbox Code Playgroud)
生成一个标记文件,只是意识到该命令会产生一个1.5GB的'commontags'文件 - 比我想要的要大一点,毫无疑问.所以我想知道是否有某种压缩文件的方法并让vim仍然认出它?
我尝试通过gzip运行它,它将其转换为25MB,但我没有运气让vim使用该文件.
有任何想法吗?我将不胜感激!
/ B2S