C/C++ declared with attribute warn_unused_result
I want to read a text file with C. This is my simple ilustration code : FILE *offsetFile=NULL; char *buffer; int cbyte; cbyte = 100; buffer = (char*) calloc (cbyte, sizeof(char)); offsetFile = fopen(“listOffset.txt”, “r”); if (offsetFile==NULL) { exit(0); } fgets (buffer, cbyte, offsetFile); When I compile this code I get warning message : ignoring [...]
Eclipse : add automatic include folder
Eclipse is a C, C++, Java and other programming language editor. I use this editor to create program with C/C++. When I use this editor, I have a problem to add include directory to eclipse editor. Right click at your project folder in Eclipse and choose Properties (Alt+Enter). Locate and click Paths and Symbols menu. [...]
C/C++ Get The Program Execution Time
When we crate a program, we can get time execution from our program to know how long our program running. This is a code how to get time execution from our program with C/C++. Create a main.c file and copy this code to that file. #include <time.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char [...]
C/C++ create random noise (gaussian noise/white noise)
I was amazed when use randn command at Matlab. randn command will generate random data every we call that command. After I search at google, I found how to make this happen. I get this code at seismic unix source code. This code will generate random noise or white noise with Gaussian method. Code for [...]
