Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the use of (Underscore) in C?

Tags:

c

identifier

I was seeing this code

#include <stdio.h>
main(t,_,a)
char *a;
{
return!0<t?t<3?main(-79,-13,a+main(-87,1-_,main(-86,0,a+1)+a)):
1,t<_?main(t+1,_,a):3,main(-94,-27+t,a)&&t==2?_<13?
main(2,_+1,"%s %d %d\n"):9:16:t<0?t<-72?main(_,t,
"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l+,/n{n+,/+#n+,/#\
;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l \
q#'+d'K#!/+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# \
){nl]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#n'wk nw' \
iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \
;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;#'rdq#w! nr'/ ') }+}{rl#'{n' ')#\
}'+}##(!!/")
  :t<-50?_==*a?putchar(31[a]):main(-65,_,a+1):main((*a=='/')+t,_,a+1)
    :0<t?main(2,2,"%s"):*a=='/'||main(0,main(-61,*a,
"!ek;dc i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);
}

and I saw this _ main()

I never saw this sign in use and never read about anywhere,
what is it used for?

like image 405
Mukul Kumar Avatar asked Dec 18 '22 11:12

Mukul Kumar


2 Answers

It's just an identifier, it's valid. You can use _ by itself as an identifier.

For example you can do this

int _;

that makes _ a variable of type int.

The code though, exposes a fundamental problem because it calls main() from within the program. Doing so, invokes undefined behavior.

like image 60
Iharob Al Asimi Avatar answered Mar 02 '23 02:03

Iharob Al Asimi


The underscore is one of the characters allowed in the names of variables and functions in C. It's not commonly used, especially at the begin or end of names. For this reason, so it's sometimes useful for:

  • Defining a variable name in a library that is not likely to clash with another name in the same scope;
  • Writing confusing code.

Your example uses it in the second version, for example by defining a variable simply called _.

like image 25
odisseas Avatar answered Mar 02 '23 03:03

odisseas