simple conversion from C to C++

From: news.hku.hk (billychu_at_hkusua.hku.hk)
Date: 04/30/04


Date: Sat, 1 May 2004 00:43:26 +0800

can any one translate the following codes into c++ codes, coz i can't run
the "printf" command in Unix and it said it's implicit declaration.
Is it only the two lines with comment need to be re-written??
Thanks a lot

void _display_number(int v, int n){
     if(v >= 1000){
            int r = v % 1000;
            _display_number(v / 1000,n);
            printf(",%03d",r); // how to translate that into
std::cout<<...?
     }else{
            printf("%s%d\n",n ? "-":"",v); // how to translate
     }
}

void display_number(int v){
     _display_number(v < 0 ? -v : v,v < 0);
}



Relevant Pages

  • INTERNAL COMPILER ERROR
    ... these are my codes for image processing...im not sure why im getting this " ... void CAboutDlg::DoDataExchange ... BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) ... void CFvasDlg::OnSysCommand(UINT nID, LPARAM lParam) ...
    (microsoft.public.vc.mfc)
  • how to explain the thread3 from the Bengining Linux Programming 3rd edition.
    ... that, he changes some about the thread3.c, below is the codes after ... can semaphore get increased since work_area value has changed, ... void *thread_function; ...
    (comp.os.linux.development.apps)
  • Re: how to implement IBindingList
    ... But problem is no sample codes. ... Just don't know how to start coding for ... >> void IBindingList.ApplySort(PropertyDescriptor property, ListSortDirection ...
    (microsoft.public.dotnet.languages.csharp)
  • simple conversion from C to C++
    ... can any one translate the following codes into c++ codes, ... the "printf" command in Unix and it said it's implicit declaration. ... void _display_number{ ...
    (comp.lang.c)
  • How to change Swing app to JApplet
    ... how to change a Swing app to a JApplet? ... what should I change in codes? ... public static void main{ ...
    (comp.lang.java.programmer)