Neueste Bilder

fuer Anhang

Anwendungsprobleme

Angebote

Benutzeranmeldung

CAPTCHA
Wie lautet das Ergebniss?
8 + 0 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Tutoials

Caesar Verschlüsselung mit Buchstaben. Problem

Viele Foren von Tutorials.de - Mai 19, 2010 - 08:25
Guten Morgen,

Ich möchte gerne einen Caesar Verschlüsselung nur mit Buchstaben schreiben.
Soweit so gut. Nun habe ich den Code schon. Allerdings soll das ganze als *.txt Datei ausgegeben werden, wo auch schon mein Problem ist.

Die Ausgabe mit cout klappt. <- d.h. der Code funktioniert!
Die Ausgaebe als *.txt klappt nicht <- Was ist da falsch ?

Code: #include <iostream>
#include <string>

using namespace std;


  FILE *hostdatei;
  string text = "Hello agian";
   
   
string CaesarCipher(string str, int gap)
{
    char lower_last = 'z' - gap;
    char upper_last = 'Z' - gap;
   
    for (unsigned int i = 0; i < str.length(); i++)
    {
        if ((str[i] >= 'a' && str[i] <= lower_last) || (str[i] >= 'A' && str[i] <= upper_last))
            str[i] += gap;
        else if (str[i] >= lower_last && str[i] <= 'z')
            str[i] = 'a' + str[i]-lower_last-1;
        else if (str[i] >= upper_last && str[i] <= 'Z')
            str[i] = 'A' + str[i]-upper_last-1;
    }
    return str;
}




int main()
{
  int gap = 4;

  string encrypted = CaesarCipher(text, gap);
 
  hostdatei = fopen("C:\\encode.txt","w");
  fprintf(hostdatei,"encode\n\n  %s ", encrypted);
  fclose(hostdatei);
 

  string decrypted = CaesarCipher(encrypted, 26-gap);
 
  hostdatei = fopen("C:\\decode.txt","w");
  fprintf(hostdatei,"decode\n\n  %s ", decrypted );
  fclose(hostdatei);
 
  system("PAUSE");
  return 0;
} Quelle des Orginalcodes

Meine Fehlermeldung
Code: 39 [Warning] cannot pass objects of non-POD type `struct std::string' through `...'; call will abort at runtime
46 [Warning] cannot pass objects of non-POD type `struct std::string' through `...'; call will abort at runtime Wie muss ich encrypted und decrypted denn Ausgeben oder was sagt mir die Fehlermeldung ?

Gruß Punish
Kategorien: Tutoials

Formeln

Viele Foren von Tutorials.de - Mai 19, 2010 - 07:44
Hallo!
Ich bräuchte für ein kleines Projekt die Möglichkeit, Formeln darstellen zu können, in etwa wie die Funktion im openoffice, wo ich z.B. schreibe: Code: {32 cdot x} over {y} und raus kommt (quasi) das Bild eines Bruches, also eine schöne Formel. Gibt es etwas ähnliches für Javascript, bzw. für PHP? Beim jquery hab ich auf die schnelle nichts gefunden...

lg
klanawagna
Kategorien: Tutoials

Formeln

Viele Foren von Tutorials.de - Mai 19, 2010 - 07:44
Hallo!
Ich bräuchte für ein kleines Projekt die Möglichkeit, Formeln darstellen zu können, in etwa wie die Funktion im openoffice, wo ich z.B. schreibe: Code: {32 cdot x} over {y} und raus kommt (quasi) das Bild eines Bruches, also eine schöne Formel. Gibt es etwas ähnliches für Javascript, bzw. für PHP? Beim jquery hab ich auf die schnelle nichts gefunden...

lg
klanawagna
Kategorien: Tutoials

Januar 1, 1970 - 02:00
Inhalt abgleichen

Powered by Drupal - Design by Artinet