1.2 KiB
1.2 KiB
Snippets
- Including bash scrips
#include <cstdlib> // For the system function
int main() {
// Replace "your_script.sh" with the actual path to your bash script
const char* scriptPath = "your_script.sh";
// Run the bash script using the system function
int result = system(scriptPath);
// Check the result of the system call
if (result == 0) {
// The script was executed successfully
// Add your FLTK code or other logic here
} else {
// There was an error executing the script
// Handle the error or display a message
}
return 0;
}
- Replacing first set of characters with a particular character(memset) Description : The C library function void *memset(void *str, int c, size_t n) copies the character c (an unsigned char) to the first n characters of the string pointed to, by the argument str. Application : Can be used to set all array to 0
// Program to replace first 7 bytes with $ symbol
#include <stdio.h>
#include <string.h>
int main () {
char str[50];
strcpy(str,"This is string.h library function");
puts(str);
memset(str,'$',7);
puts(str);
return(0);
}
Output
This is string.h library function
$$$$$$$ string.h library function