Visualizzazione dei risultati da 1 a 2 su 2

Discussione: [C++]Problemino

  1. #1

    [C++]Problemino

    Sto scrivendo un mail sender in C++ ma sono bloccato da un problema........
    codice:
    // main .cpp
    #include <iostream>
    #include <cstdlib>
    #include <cstring>
    #include "mail.h"
    
    using namespace std;
    
    int main( int argc, char *argv[] )
    {
      
      system( "PAUSE" );	
      return 0;
    }
    codice:
    #ifndef MAIL_H_
    #define MAIL_H_
    #include <string>
    
    using namespace std;
    // sending mail
    void send( mail *, string, string, string, char*[] );
    // the max size of mail object
    #define BUFFER 2048
    
    struct mail
    {
        string from;// the sender
        string to;// the receiver
        string object;// the object
        char *text[BUFFER];// the text
        string header;// the complete header
    };
    
    void send( mail * ml, string from, string to, string object, char* text[BUFFER])
    {
        if( ( from == " " ) || ( to == " " ) || ( object == " " ) || ( strcmp(text, " ") == true ) )
        {
            cout << "A part of the email is null, retry\t";
            return;
        }else{    
            ml->from = from;
            ml->to = to;
            ml->object = object;
            ml->text = text;
        }
        /* this part of function create the mail header and prepare it to send but I can't do at time :/ */
    }
    #endif
    Compilatore: Default compiler
    Building Makefile: "C:\Documents and Settings\Francesca\Desktop\Luca\Progetti C++\mail\Makefile.win"
    Esecuzione di make...
    make.exe -f "C:\Documents and Settings\Francesca\Desktop\Luca\Progetti C++\mail\Makefile.win" all
    g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/include/c++" -I"C:/Dev-Cpp/include/c++/mingw32" -I"C:/Dev-Cpp/include/c++/backward" -I"C:/Dev-Cpp/include"

    In file included from main.cpp:5:
    mail.h:7: `mail' was not declared in this scope
    mail.h:7: parse error before `,' token
    mail.h: In function `void send(mail*, std::basic_string<char,
    std::char_traits<char>, std::allocator<char> >, std::basic_string<char,
    std::char_traits<char>, std::allocator<char> >, std::basic_string<char,
    std::char_traits<char>, std::allocator<char> >, char**)':
    mail.h:22: cannot convert `char**' to `const char*' for argument `1' to `int
    strcmp(const char*, const char*)'
    mail.h:30: incompatible types in assignment of `char**' to `char*[2048]'

    make.exe: *** [main.o] Error 1

    Esecuzione terminata

    Tnk 1000k
    La stupidità umana e l'universo sono infinite.
    Della seconda non sono certo(Einstein)

    Gnu/Linux User

  2. #2
    Utente di HTML.it
    Registrato dal
    Jan 2002
    Messaggi
    633
    dovresti definire la struct mail prima di dichiarare la funzione send (che prende come parametro proprio un mail*).
    Se non fai così, al momento della dichiarazione il compilatore non conosce mail e ti segnala l'errore.

    Poi, non ricordo se sia un errore o meno (non mi pare), ma è più elegante e leggibile se metti tutti i tuoi #define (e le direttive per il preprocessore) riuniti.

    ciauz
    Alcuni miei articoli in PRO.HTML.IT: JavaScript | DHTML | DOM
    Sviluppo : wedev | forum

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.