Try and cause a segmentation fault but use as few characters as possible

I am trying and cause a segmentation fault by using as few characters as possible.
Please help Thanks

#include iostream  

int main(int argc, char** argv) {
  std::cout << "argc="<<argc<<" argv="<<"argc="<<argv<<std::endl;

  return 0;
}

Sounds like a candidate for code golf.

1 Like

Welcome @loving_programming,

aside from the fact that #include iostream is syntactically incorrect, your code looks pretty pointless. What is the intention behind it?

To produce a segfault, you can e.g. dereference a noninitialized pointer:

int main(){int *x;return *x;}
3 Likes

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.