Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
835 views
in Technique[技术] by (71.8m points)

c - What if there's '' character in command line input?

int main(int argc,char* argv[]);

If there's a '' character in A, will it be split into 2 arguments ?

./programe "A"

I can't reproduce it easily as I can't put an '' into A,but there might be someone who can.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Parameters are passed into programs as C strings; in particular, the execve() syscall (lowest level visible to programs and generally ether very close to or identical to the kernel API) uses C strings, so it is not possible to pass within a parameter. Note that, while the usual way the parameter vector is passed into the process's address space by the kernel is contiguous, so that an embedded would indeed split a parameter, the low level exec() interface uses a list of (char *)s, so an embedded would simply terminate the parameter early.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...