duangsues.is_a? SaltedFish
#android 杂项。
This media is not supported in your browser
VIEW IN TELEGRAM
#microsoft #cplusplus #qq #China #dev 感觉 C 的动态堆上分配 malloc, 栈上 alloca 暴露指针带来很大问题啊,不说 char 长度这些“不严重”的问题了,“先过一遍取size”,拒绝大小动态增长到底好不好?值不值得?
你是怎么想到
//typedef ifstream fs;
fs in("");
fs ip("");
这种命名的,第二个以后还是叫 in1 之类的靠谱些,命名要注意包含语义,不能 i,j,k,n,m 那样乱起
而且要积极定义函数,比如说你这个分配并读取到数组a 的,其实只有 ifstream 一个变量(stream 可以重置不必 reopen)
再说简单点可以做成 list<string> readFileLines(string file_path);
(因为 C 数组实际上只是带元素类型的指针,损失了长度 size() 信息,必须用 stl 即 std 的 list<T> )
稍微查一下 cppreference.com 就可以发现有 getline() API:
https://en.cppreference.com/w/cpp/io/basic_istream/getline
科学上网到 google, duck.com, bing.com 去搜啊, StackOverflow 很多这样的回答,都是能直接复制粘贴的。
程序员最不能缺的就是信息来源,不然就和玩码的农夫没有区别
https://stackoverflow.com/questions/13035674/how-to-read-line-by-line-or-a-whole-text-file-at-once 这,一个直接的用例
我自己是 unix 系程序猿而且不怎么搞 C++ 的 GUI 设计,不可能帮你写嘛
你是怎么想到
//typedef ifstream fs;
fs in("");
fs ip("");
这种命名的,第二个以后还是叫 in1 之类的靠谱些,命名要注意包含语义,不能 i,j,k,n,m 那样乱起
而且要积极定义函数,比如说你这个分配并读取到数组a 的,其实只有 ifstream 一个变量(stream 可以重置不必 reopen)
再说简单点可以做成 list<string> readFileLines(string file_path);
(因为 C 数组实际上只是带元素类型的指针,损失了长度 size() 信息,必须用 stl 即 std 的 list<T> )
稍微查一下 cppreference.com 就可以发现有 getline() API:
https://en.cppreference.com/w/cpp/io/basic_istream/getline
科学上网到 google, duck.com, bing.com 去搜啊, StackOverflow 很多这样的回答,都是能直接复制粘贴的。
程序员最不能缺的就是信息来源,不然就和玩码的农夫没有区别
https://stackoverflow.com/questions/13035674/how-to-read-line-by-line-or-a-whole-text-file-at-once 这,一个直接的用例
我自己是 unix 系程序猿而且不怎么搞 C++ 的 GUI 设计,不可能帮你写嘛
Stack Overflow
How to read line by line or a whole text file at once?
I'm in a tutorial which introduces files (how to read and write from\to file)
First of all, this is not a homework, this is just general help I'm seeking.
I know how to read one word at a time, b...
First of all, this is not a homework, this is just general help I'm seeking.
I know how to read one word at a time, b...
#statement 开始我各种不理解 #Python 的 encode, decode (分不清,后来就提了一个:decode 可能出错、encode 得 bytes )
现在我觉得 Py 的一些东西相对 C 算好的了…… 它至少不让你处理 size 和 allocation ,不会到处弄
现在我觉得 Py 的一些东西相对 C 算好的了…… 它至少不让你处理 size 和 allocation ,不会到处弄
size_t op(void* dst, 这种东西#mfc 上面的👆(不过话说 C++ basic_string/*= string*/::getline 竟然只支持静态大小 buf ,得用 std::getline 来搞上 string 欸)
中Format:没有与参数列表匹配的重载函数
参数类型为: (const char [3], int)
对象类型是: CString
duangsuse 13:51:41
你是不是少加 &b 取 (int*) 了
传指针地址,不然 CString::Format(fmtstr, ...outs) 怎么用
duangsuse 13:53:30
不对…… 你们 MFC 是这么搞,我们叫 asprintf 的
这样看 CString str; str.Format("%d", 1); str 就没毛病,实在不行可以试 itoa(1)
腾讯新聞 14:01:54
/泪奔我还是看mfc 0基础教程吧
duangsuse 14:02:02
去网上查: MFC CString format 用法
可能是你 API 用错了,format 不是那个意思,怎么可能没有对应的函数版本
"ATL::CStringT< BaseType, StringTraits >::Format [其中BaseType=wchar t,StringTraits= Str TraitMFC <wchar _t, ATL::ChTraitsCRT <wchar _t>>]"实例参数类型为: (const char [3], int)
对象类型是: CString
duangsuse 13:51:41
你是不是少加 &b 取 (int*) 了
传指针地址,不然 CString::Format(fmtstr, ...outs) 怎么用
duangsuse 13:53:30
不对…… 你们 MFC 是这么搞,我们叫 asprintf 的
这样看 CString str; str.Format("%d", 1); str 就没毛病,实在不行可以试 itoa(1)
腾讯新聞 14:01:54
/泪奔我还是看mfc 0基础教程吧
duangsuse 14:02:02
去网上查: MFC CString format 用法
可能是你 API 用错了,format 不是那个意思,怎么可能没有对应的函数版本
duangsuse::Echo
#Python #zhihu https://zhuanlan.zhihu.com/p/27141891 这个有意思, pygame 歌词打轴制作
想想我现在也写了一个,还没有十行(迫真
但是他这个真的……
但是他这个真的……
if ev==mouseDown { n++; if n%m==1,2,3 } 重复了三遍,除了一 img 变量外相同的逻辑,动苏不喜欢这样的代码,既多敲了键盘,又封死了动态 list 化、最大化利用代码实现程序功能的可能。Telegram
duangsuse::Echo
开个小差( #Python #code https://paste.ubuntu.com/p/5kNyQYJXCK/ #linux #tools #cli
还记得之前的曲子吗?弄个简单的 lrc 歌词制作,不需要 async getchar() 。
from subprocess import Popen
from time import time
class LrcRepr:
def show(lines): return "".join([f"[%02d:%02d.%02d]%s" %(t/60…
还记得之前的曲子吗?弄个简单的 lrc 歌词制作,不需要 async getchar() 。
from subprocess import Popen
from time import time
class LrcRepr:
def show(lines): return "".join([f"[%02d:%02d.%02d]%s" %(t/60…
Forwarded from dnaugsuz
这个东西其实也没有那么艰难困坚的,上/下界指的是 Object..Void (kotlin Any?..Nothing, 即类型的 顶..底)
说白了就是这个区间里的子类型约束, (T1 super T) 是限上, (T1 extends T) 是限下, Kt 里前者是 <in T> 后者是 <out T> , * projection 在 in/out 分别代表 in-Nothing/out-Any?,比 Java 的 <?> 无检查安全得多。
这个问题有点复杂,我一篇文章居然最后没讲完全,但是肯定够用了
说白了就是这个区间里的子类型约束, (T1 super T) 是限上, (T1 extends T) 是限下, Kt 里前者是 <in T> 后者是 <out T> , * projection 在 in/out 分别代表 in-Nothing/out-Any?,比 Java 的 <?> 无检查安全得多。
这个问题有点复杂,我一篇文章居然最后没讲完全,但是肯定够用了
Forwarded from dnaugsuz
也是怪我写得太随性,要是我紧扣议题,讲明白 Kotlin 里 Array<T> 和 Array<out T> 是不同类型的这类事实去做对比,就会更容易理解了。
Forwarded from dnaugsuz
可以这么理解,反过来就是逆变
Function<in T, out R> 里 T (实际)收 super T 的, R 收 extends R 的
比如
Function<in T, out R> 里 T (实际)收 super T 的, R 收 extends R 的
比如
(o as Func<Number, CharSequence> as Func<Int, String>) ,其中 (o as A as B) 也就是说若有 op(B) 则 op(A) 正确、合规Forwarded from みつき そはら | 椒鹽九肚魚🐟 | 努力學習中!
C++ 是你可以把子類別 cast 成父類別,或者傳指計/引用 因為子類的成員總在父類後面(?)