-   Linux - Newbie (
-   -   where do the results print? (

Mehedi Hasan 09-14-2014 01:23 PM

where do the results print?
In file where or in which file the results print?

printf("Min_cost = %f\nlast_iter = %d\nCH are:\n", min_cost, last_iter);
for (int i=0; i<p_; i++)
printf("%f\t%f\t%d\n", ch_X[i], ch_Y[i], ch_index[i]);

I cann't understand whether my change code in file is working or not...

plz can anyone help me how i can see my change results in any file like .txt or tcl file.

thanks in advance...

Ser Olmy 09-14-2014 01:59 PM

printf writes to stdout, so any output will appear in the terminal window (unless stdout is redirected with > or a pipe, of course).

Mehedi Hasan 09-14-2014 02:52 PM


I am using cygwin terminal...But i cann't see the output...

what is fflush(stdout)?

Ser Olmy 09-14-2014 02:57 PM

fflush makes sure any cached data is "flushed" to the file stream; see here for more information.

You're saying you're running the program manually in a cygwin terminal window, but you're not seeing any output at all?

Mehedi Hasan 09-14-2014 03:06 PM

in cygwin terminal i only give the command

how can i run manually?

Ser Olmy 09-14-2014 03:17 PM


The make command will, under the right circumstances, compile your program. That is, convert the stuff you've written in C or C++ into something the computer can actually run.

Take a look in the directory where you ran the make command. There should be a new file there, one that wasn't there before you ran make. That's the program, and you must type the name of that file preceded by "./" to run it. Example: ./myprogram.o.

Mehedi Hasan 09-14-2014 03:45 PM

It makes this error

./bsagent.o :can not read binary file

in the directory mit/uAMPS bsagent.o file is created after running the 'make' command

btmiller 09-14-2014 04:17 PM

A .o file is usually an object file, not an executables. Object files must be linked to produce an executable. Usually this is handled by the Makefile. Are you sure there's no executable in your directory after typing "make"? Did you not get any instructions for how to run the program?

Mehedi Hasan 09-15-2014 01:42 AM


plz tell me the procedure how i can see the printed results from file...

I have installed Leach protocol in ns-2.34 in windows XP...

I run the program from cygwin terminal...

first i 'make' the file then run './leach_test' which produce results in leach_sims folder...
but i cann't see the printed values in any file...

new in ns-2

plz support me the best as you can...


All times are GMT -5. The time now is 09:28 PM.