小编Sie*_*geX的帖子

用什么语言来启动我对OOP的学习?

因为最近的工作职责,我是一名硬件工程师,成为软件工程师.我对过程式编程有很强的理解(主要是'C'和'bash'脚本),但我只知道OOP是什么.

我环顾四周,几乎所有现代语言都有非常坚定的OOP(C++,java,python,ruby等).我现在觉得我已经准备好将我的大脑用于新的概念,而OOP是你的工具带中现在需要的日子.我的问题是,有了'C'的强大背景,C++是学习OOP的合乎逻辑的下一步,还是我会错过一些只有其他语言提供的有用结构,例如java?

谢谢大家.

oop

1
推荐指数
1
解决办法
325
查看次数

在 bash 变量/数组中使用特殊字符

我在 bash 脚本中声明数组中的所有可打印字符时遇到问题。I\xe2\x80\x99d 喜欢通过循环 4 次显示所有可打印字符。

\n\n

例子

\n\n
array=( a b c d \xe2\x80\xa6 z A B C \xe2\x80\xa6 Z 1 2 3 \xe2\x80\xa6 0 ! @ # $ % ^ & * ( ) _ +)\n\nFor chr1 in ${array[@]} \nDo\nFor chr2 in ${array[@]}\nDo \nEcho $chr1$chr2\nDone\nDone\n
Run Code Online (Sandbox Code Playgroud)\n\n

我已经能够使用 ${array[value of space]} 获取要打印的空格字符,但我仍然无法获取要打印的 * 字符。由于某种原因,它倾向于打印文件列表。

\n\n

知道如何让它发挥作用吗?

\n

bash osx-snow-leopard

1
推荐指数
1
解决办法
4395
查看次数

unix 删除重复的行块,先保留

这是我 TWS 数据库中工作的摘录,我的块以:

/^ES2BVE1011 # EM5341CAI000 (jobname)
Run Code Online (Sandbox Code Playgroud)

并以:

/^ RECOVERY (can be STOP ou CONTINUE) 
Run Code Online (Sandbox Code Playgroud)

我有重复的块,我只想保留第一个以最大限度地减少加载时间,前提是整个块都具有相同的行,因为它可以是相同的作业名称,但块中的其他行可能存在差异:

ES2BVE1011 # EM5341CAI000  
 SCRIPTNAME "/s2ipgm/scripts/current/em5341cai000.sh -scai -eexp"  
 STREAMLOGON us2icai  
 DESCRIPTION "balance sheet errors"  
 UNIX TASKTYPE  
 SUCCOUTPUTCOND CONDSUCC "(RC = 0)"  
 RECOVERY STOP  
ES2BVE1011 # ED5237CAI001  
 SCRIPTNAME "/s2ipgm/scripts/current/ed5237com001.sh -scai -eexp"  
 STREAMLOGON us2icai  
 DESCRIPTION "bb / ir account list"  
 UNIX TASKTYPE  
 SUCCOUTPUTCOND CONDSUCC "(RC = 0)"  
 RECOVERY STOP  
ES2BVE1011 # CA4305CAI000  
 SCRIPTNAME "/s2ipgm/scripts/current/ea4305com000.sh -scai -ecpt"  
 STREAMLOGON us2icai  
 DESCRIPTION "list op. Fid."  
 UNIX TASKTYPE  
 SUCCOUTPUTCOND CONDSUCC "(RC …
Run Code Online (Sandbox Code Playgroud)

unix bash shell awk duplicates

1
推荐指数
1
解决办法
111
查看次数

从C中的文件路径中解析文件扩展名

我以前使用以下代码来确定文件是.exe或.o文件,从而将binFile设置为1:

if(strstr(fpath,".exe") != NULL || strstr(fpath,".o") != NULL)
          binFile = 1;
Run Code Online (Sandbox Code Playgroud)

通过调试,我注意到这个方法也会使用foo.out或foo.execute等文件将binFile设置为1.我真正想要的是匹配'.exe\0'和'.o\0',但是strstr()说它忽略了终止的NUL字节.我该怎么办呢?

谢谢

c string file

0
推荐指数
1
解决办法
2775
查看次数

在C中以各种类别对整数进行bin/map的优雅方法是什么?

假设我们有一个整数'x'和'n'可能的值'x'可以映射/分箱到.在C中有一个优雅的方法是有一个函数可以将最接近的'nth'值返回给x?

伪代码示例;

int x = 40;
int res;
int bins[] = { 0, 20, 80, 200 }; /* Sorting is guaranteed */

res = int_bin(x, bins);
assert(res == 20); /* 40 is closer to 20 than 80 */

x = 150;

res = int_bin(x, bins);
assert(res == 200); /* 150 is closer to 200 than 80 */
Run Code Online (Sandbox Code Playgroud)

优雅我的意思不仅仅是一堆if/else if/else语句.

c algorithm search binary-search

0
推荐指数
1
解决办法
149
查看次数

如何在perl脚本中插入awk命令?

我想在我的脚本上添加这个awk命令,但一直收到错误.我已经放入""但仍然出错.

system("awk -F"\t" '{ for ( i=1; i<=2; i++ ) { printf "%s\t", $i } printf "\n"; }' myfile file2"};
Run Code Online (Sandbox Code Playgroud)

错误是

找到运算符在host_parse第21行预期的位置,靠近"t"'{for(i = 1; i <= 2; i ++){printf""

未加引号的字符串"a"可能与myfile第58行的未来保留字冲突.

未加引号的字符串"a"可能与myfile第58行的未来保留字冲突.

myfile第21行的语法错误,靠近""awk -F"\"

谢谢.

linux perl awk

0
推荐指数
1
解决办法
4379
查看次数

unix - awk - 在用户定义的函数中打印参数名称

在bash脚本中使用下面的awk说:

如何让print_line函数打印传入的参数的名称?即这个输出

array passed in was:
arrayprime
array passed in was:
arraymagic
Run Code Online (Sandbox Code Playgroud)

只是代码要点的片段(不是整件事):

awk -F"$delim" '
NR>1 { 

        print_line(arrayprime)
        print_line(arraymagic)
}
    func print_line(arr)
    {
        print "array passed in was:"
            print arr
    }

} ' "$filename"
Run Code Online (Sandbox Code Playgroud)

unix linux bash shell awk

0
推荐指数
1
解决办法
370
查看次数

Shell scripting- processing hidden files

I'm working on a project where I have to process the contents of a directory passed in as an argument, and I need to include invisible files (ones that start with .) as well. This is how I'm approaching it

#!/bin/bash

cd $1
for file in `dir -a -d * `;
do
#more code blah blah 
Run Code Online (Sandbox Code Playgroud)

even though I use the -a tag on the dir command, it still ignores invisible files. Any ideas why?

bash shell file

0
推荐指数
1
解决办法
720
查看次数

如何使用awk进行无限循环

我有一个程序:

#!/bin/awk -f
BEGIN {
}
{
        print "hello"       
}
END {
}
Run Code Online (Sandbox Code Playgroud)

它打印你好,然后等待输入被按下然后再打印你好.我想在不要求进入的情况下让它无限.请评论!

awk loops infinite

-1
推荐指数
2
解决办法
929
查看次数

标签 统计

awk ×4

bash ×4

shell ×3

c ×2

file ×2

linux ×2

unix ×2

algorithm ×1

binary-search ×1

duplicates ×1

infinite ×1

loops ×1

oop ×1

osx-snow-leopard ×1

perl ×1

search ×1

string ×1