???
 
       
      ???
 thomas woelfer
thomas woelfer  Schaub-Johannes „ULONGLONG in CString umwandeln (C++)“
Schaub-Johannes „ULONGLONG in CString umwandeln (C++)“
      
          siehe z.b. CValidateObject::ConvertNumber aus ATL. liefert einen LPCTSTR und denn kann man leicht in einen CString umwandeln...
          
          WM_HOPETHISHELPS
          thomas woelfer
        
 thomas woelfer
thomas woelfer  Schaub-Johannes „ULONGLONG in CString umwandeln (C++)“
Schaub-Johannes „ULONGLONG in CString umwandeln (C++)“
      
          achso - nochwas: ULONGLONG in string geht natuerlich auch mit sprintf()...
          
          WM_FYI
          thomas woelfer
        
 Schaub-Johannes
Schaub-Johannes  thomas woelfer „achso - nochwas: ULONGLONG in string geht natuerlich auch mit sprintf ... WM_FYI...“
thomas woelfer „achso - nochwas: ULONGLONG in string geht natuerlich auch mit sprintf ... WM_FYI...“
      Wie? Ich programmiere in Windows. sprintf ist doch nur für dos zu drucken oder?
 thomas woelfer
thomas woelfer  Schaub-Johannes „Wie? Ich programmiere in Windows. sprintf ist doch nur für dos zu drucken oder?“
Schaub-Johannes „Wie? Ich programmiere in Windows. sprintf ist doch nur für dos zu drucken oder?“
      
          das taeuscht du dich. sprintf hat mit dos ueberhaupt gar nichts zu tun sondern ist eine der verschiedenen string-formatierungsfunktionen der ansi 'c' bibliothek. bei der 's' variante handelt es sich um die, die einen oder mehrere parameter in einen string umformatiert und dabei eine formatanweisung in form eines weiteren strings verwendet. sollte ganz genau das sein, was du willst...
          
          WM_HOPETHISHELPS
          thomas woelfer
        
 Schaub-Johannes
Schaub-Johannes  thomas woelfer „das taeuscht du dich. sprintf hat mit dos ueberhaupt gar nichts zu tun sondern...“
thomas woelfer „das taeuscht du dich. sprintf hat mit dos ueberhaupt gar nichts zu tun sondern...“
      Kannst du mir mal ein kleines Beispiel posten wie man das macht? Das brauche ich nämlich für den Priemzahlenermittler.
 thomas woelfer
thomas woelfer  Schaub-Johannes „Kannst du mir mal ein kleines Beispiel posten wie man das macht? Das brauche ich...“
Schaub-Johannes „Kannst du mir mal ein kleines Beispiel posten wie man das macht? Das brauche ich...“
      
          // puffer fuer resultat
          char sz[ 1024];
          
          // grosse zahl
          ULONGLONG n = 4;
          
          // zahl in string, gemaess format
          sprintf( sz, "I64u", n);
          
          das format gibt an, was fuer ein datentyp
          zu erwarten ist und wie die daten daraus
          im string zu formatieren sind. 'u' := unsigned int
          und I64 = 64 bit int. (siehe online docu zu
          sprintf())
          
          WM_HOPETHISHELPS
          thomas woelfer
          
          
        
 Schaub-Johannes
Schaub-Johannes  thomas woelfer „// puffer fuer resultat char sz 1024 // grosse zahl ULONGLONG n 4 // zahl in...“
thomas woelfer „// puffer fuer resultat char sz 1024 // grosse zahl ULONGLONG n 4 // zahl in...“
      Wenn ich das mache ist in sz nur "i64u" enthalten
 Schaub-Johannes
Schaub-Johannes  thomas woelfer „// puffer fuer resultat char sz 1024 // grosse zahl ULONGLONG n 4 // zahl in...“
thomas woelfer „// puffer fuer resultat char sz 1024 // grosse zahl ULONGLONG n 4 // zahl in...“
      Das geht nicht! Dann steht in sz i64u
 thomas woelfer Nachtrag zu: „// puffer fuer resultat char sz 1024 // grosse zahl ULONGLONG n 4 // zahl in...“
thomas woelfer Nachtrag zu: „// puffer fuer resultat char sz 1024 // grosse zahl ULONGLONG n 4 // zahl in...“
      
          ja, sorry - du must die format angabe natuerlich mit % einleiten (siehe sprintf() dokumentation...), also sprintf( sz, "%i64u", n);
          
          WM_HOPETHISHELPS
          thomas woelfer
        
 Schaub-Johannes
Schaub-Johannes  thomas woelfer „ja, sorry - du must die format angabe natuerlich mit einleiten siehe sprintf...“
thomas woelfer „ja, sorry - du must die format angabe natuerlich mit einleiten siehe sprintf...“
      
          Wenn ich jetzt aber dir Zahl 200 umwandeln will bekomme ich 20064u heraus:
          char Hello[255];
          ULONGLONG i3;
          i3=200;
          sprintf(Hello,"%i64u",i3);
          CString h;
          h=Hello;
          this->MessageBox(h); // = 20064u?????
        
 thomas woelfer
thomas woelfer  Schaub-Johannes „Wenn ich jetzt aber dir Zahl 200 umwandeln will bekomme ich 20064u heraus: char...“
Schaub-Johannes „Wenn ich jetzt aber dir Zahl 200 umwandeln will bekomme ich 20064u heraus: char...“
      
          tja, nochmals sorry: hatte das auswendig hingeschrieben. steht aber richtig (wie bereits erwaehnt) in der sprintf() docu. der richtige
          formatstring ist "%I64d" - das 'grosse' I ist dabei wichtig, und fuer den integer muss es natuerlich ein d und kein u sein...
          
          WM_HOPETHISHELPS
          thomas woelfer
        
 Schaub-Johannes
Schaub-Johannes  thomas woelfer „tja, nochmals sorry: hatte das auswendig hingeschrieben. steht aber richtig wie...“
thomas woelfer „tja, nochmals sorry: hatte das auswendig hingeschrieben. steht aber richtig wie...“
      
          Hab noch ne andere Methode gefunden:
          
          char *_i64toa( __int64 value, char *string, int radix );
        
 Schaub-Johannes
Schaub-Johannes  thomas woelfer „tja, nochmals sorry: hatte das auswendig hingeschrieben. steht aber richtig wie...“
thomas woelfer „tja, nochmals sorry: hatte das auswendig hingeschrieben. steht aber richtig wie...“
      aber ist daß auch für ULONGLONG oder nur für LONGLONG? Oder beides
 thomas woelfer
thomas woelfer  Schaub-Johannes „aber ist daß auch für ULONGLONG oder nur für LONGLONG? Oder beides“
Schaub-Johannes „aber ist daß auch für ULONGLONG oder nur für LONGLONG? Oder beides“
      
          ich wuerde vorschlage du liesst einfach mal die bereits mehrfach erwaehnte dokumentation zu sprintf().
          
          WM_GOODLUCK
          thomas woelfer
        
 Schaub-Johannes
Schaub-Johannes  thomas woelfer „ich wuerde vorschlage du liesst einfach mal die bereits mehrfach erwaehnte...“
thomas woelfer „ich wuerde vorschlage du liesst einfach mal die bereits mehrfach erwaehnte...“
      Wo gibts die Dokumentation denn? In meiner c++-Hilfe steht darüber nichts geschrieben
 thomas woelfer
thomas woelfer  Schaub-Johannes „Wo gibts die Dokumentation denn? In meiner c -Hilfe steht darüber nichts...“
Schaub-Johannes „Wo gibts die Dokumentation denn? In meiner c -Hilfe steht darüber nichts...“
      
          wenn du vc++ benutzt: sprintf eintippen, mit dem cursor draufgehen und f1 druecken.
          
          ansonsten z.b. hier: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_sprintf.2c_.swprintf.asp
          
          wenn dein dokumentation nichts zum thema sprintf() erhaelt, dann solltest du aber mal darueber nachdenken eine andere entwicklungsumgebung zu verwenden... .)
          
          WM_FYI
          thomas woelfer
        
