write to a file using g_print

2012-08-21 Thread Rudra Banerjee
Is it possible to write to a file using g_print? 
I was trying something like:

  FILE *fop = g_open("bib2.bib","w");
  g_print ("%s%s",strcombo,strkey, fop);

but its not working.
Even fprintf is giving warning and not writing.
mkbib.c:114:15: warning: initialization makes pointer from integer
without a cast [enabled by default]
mkbib.c:115:3: warning: passing argument 1 of ‘fprintf’ from
incompatible pointer type [enabled by default]

Any solution?


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: write to a file using g_print

2012-08-21 Thread David Nečas
On Tue, Aug 21, 2012 at 11:42:53PM +0100, Rudra Banerjee wrote:
> Is it possible to write to a file using g_print? 

g_print() is not an interface to print things to *a specific
destination*.  Quite the opposite.

It sends messages to the print handler.  Depending on the print handler
stup, it do anything with them (print to stdout, save to some file,
display somewhere, discard, ...).

> Any solution?

Don't do that then.  Use g_fprintf().  Or, in most cases, just
fprintf().

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: write to a file using g_print

2012-08-21 Thread Ardhan Madras
g_open() is wrapper to open() syscall, not the standard libc's fopen().

> mkbib.c:114:15: warning: initialization makes pointer from integer
> without a cast [enabled by default]
You got this because g_open() returning a int (file descriptor) not a
FILE pointer.

You must distinguish each I/O method that you are using and don't mess with it.
You can't use a file descriptor to standard libc's I/O functions, use
FILE pointer instead.

#include 
#include 
#include 

FILE *fop = open("bib2.bib", "w");
/* you can call g_fprintf() or fprintf() */

see man 3 printf

> Is it possible to write to a file using g_print?
g_print() already write to standard output FILE, but you can dup()
standard output to another file.

Regards.

On Wed, Aug 22, 2012 at 6:42 AM, Rudra Banerjee  wrote:
> Is it possible to write to a file using g_print?
> I was trying something like:
>
>   FILE *fop = g_open("bib2.bib","w");
>   g_print ("%s%s",strcombo,strkey, fop);
>
> but its not working.
> Even fprintf is giving warning and not writing.
> mkbib.c:114:15: warning: initialization makes pointer from integer
> without a cast [enabled by default]
> mkbib.c:115:3: warning: passing argument 1 of ‘fprintf’ from
> incompatible pointer type [enabled by default]
>
> Any solution?
>
>
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: write to a file using g_print

2012-08-21 Thread Ardhan Madras
Sorry my bad.
> FILE *fop = open("bib2.bib", "w");
It should be fopen()

Regards.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list