Code:
int str_join(char *a, const char *b) { int sz =0; while(*a++) sz++; char *st = a -1, c; *st = (char) 32; while((c = *b++)) *++st = c; *++st = 0; return sz; } .... char a[] = "StringA"; printf("string-1 length = %d, String a = %s\n", str_join(&a[0],"StringB"), a);
Output:
string-1 length = 7, char *a = StringA StringB
*** stack smashing detected **** : /T02 terminated
Aborted (core dumped)
I don’t understand why it’s showing stack smashing? and what is *stack smashing? Or is it my compiler’s error?
Related Posts:
- Compiling a .C file: Undefined symbols for architecture x86_64
- How do I compile the asm generated by GCC?
- C Unknown type name ‘my_structure’
- Compiler gcc:error; no such file or directory
- c stack smashing detected
- Convert char to int in C and C++
- gcc makefile error: “No rule to make target …”
- gcc makefile error: “No rule to make target …”
- How does #include
work in C++? - How do I install gcc on cygwin?
- warning: incompatible implicit declaration of built-in function ‘xyz’
- libpthread.so.0: error adding symbols: DSO missing from command line
- fatal error: Python.h: No such file or directory
- Fatal error: iostream: No such file or directory in compiling C program using GCC
- conflicting types error when compiling c program using gcc
- What is a file with extension .a?
- gcc/g++: “No such file or directory”
- (.text+0x20): undefined reference to `main’ and undefined reference to function
- Interpreting valgrind error Invalid write of size 4
- difference between
and - Warning/error “function declaration isn’t a prototype”
- Error: initializer element is not computable at load time
- warning: initializer element is not computable at load time
- Debug vs Release in CMake
- Debug vs Release in CMake
- gcc error : undefined reference to `itoa’
- What is the difference between gcc/g++ and cc1/cc1plus?
- Removing trailing newline character from fgets() input
- gcc: undefined reference to
- How to repair warning: missing braces around initializer?
- Why do I get “cast from pointer to integer of different size” error?
- What happens during a “relocation has invalid symbol index” error?
- g++ output: file not recognized: File format not recognized
- What does this GCC error “… relocation truncated to fit…” mean?
- Undefined reference to main – collect2: ld returned 1 exit status
- error: unknown type name ‘bool’
- Where is the
header file on Linux? Why can’t I find ? - gcc -g :what will happen
- Make Error 127 when running trying to compile code
- File format not recognized; treating as linker script using GCC
- Gcc error: gcc: error trying to exec ‘cc1’: execvp: No such file or directory
- gcc 4.8 on MAC OS X 10.8 throws “Undefined symbols for architecture x86_64: “
- cc1.exe System Error – libwinpthread-1.dll missing – But it isn’t
- Fatal error: iostream: No such file or directory in compiling C program using GCC
- typedef fixed length array
- How to solve static declaration follows non-static declaration in GCC C code?
- Linker error: “linker input file unused because linking not done”, undefined reference to a function in that file
- GCC: Array type has incomplete element type
- I don’t understand -Wl,-rpath -Wl,
- How to compile C program on command line using MinGW?
- How big can a 64 bit unsigned integer be?
- The difference between n++ and ++n at the end of a while loop? (ANSI C)
- What is a segmentation fault?
- How many spaces for tab character(\t)?
- Implementing Taylor Series for sine and cosine in C
- Working on code to calculate cosine with factorial sum
- How to use execvp()
- How to use execvp() to execute a command
- How does strtok() split the string into tokens in C?
- What is the difference between g++ and gcc?
- warning: implicit declaration of function
- warning: implicit declaration of function
- What is *(uint32_t*)?
- What does (~0L) mean?
- What is a StackOverflowError?
- pthread_join() and pthread_exit()
- What is size_t in C?
- What is the difference between float and double?
- what is Segmentation fault (core dumped)? [duplicate]
- What causes a segmentation fault (core dump) to occur in C?
- uint8_t vs unsigned char
- How to use symbols of extended ASCII table in C?
- Two questions about basic C programs
- What is the difference between ++i and i++?
- Using boolean values in C
- What does “collect2: error: ld returned 1 exit status” mean?
- How to convert an int to string in C?
- typedef struct vs struct definitions [duplicate]
- How to print in C
- What is the effect of extern “C” in C++?
- Why should we typedef a struct so often in C?
- Why are #ifndef and #define used in C++ header files?
- Arrow operator (->) usage in C
- Differences between arm64 and aarch64
- strdup() – what does it do in C?
- strdup() – what does it do in C?
- What is a string of hexadecimal digits?
- Why should we typedef a struct so often in C?
- g++ ld: symbol(s) not found for architecture x86_64
- What exactly is the difference between “pass by reference” in C and in C++?
- What is the difference between ++i and i++?
- What can be the reasons of connection refused errors?
- What does “collect2: error: ld returned 1 exit status” mean?
- How to convert an int to string in C?
- typedef struct vs struct definitions [duplicate]
- What is newline character — ‘\n’
- When to use extern “C” in simple words? [duplicate]
- Floating point exception( core dump
- Why does ENOENT mean “No such file or directory”?
- What does the question mark character (‘?’) mean?