1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

C/C++ guide me

Discussion in 'C++' started by Rhyton, Jun 25, 2013.

  1. Rhyton

    Rhyton New Member

    Hello to everyone ,
    I have some questions , if i know php in a medium way how hard can it be to learn c/c++ ?
    2. I learned to manipulate data in php, it well be the same way in c/c++ or i need to learn some new tricks to manipulate data ?
    3.If php it's nothing like c/c++ . can you guys recomand me from experience 1 book from bottom to top which well explain every function what it is and how it's working ? and where to not put wrong numbers?
    Thanks in advance !
    (and sorry for my bad english)
     
  2. shabbir

    shabbir Administrator Staff Member

    Knowing a programming language always help but then you should understand that the extent of help you will get by knowing PHP is just you can write programs and understand logics little faster.
    Depends on how you have manipulated the data but normally it is the case that there is equivalent function in almost all programming language.
    Check out the thread I have in other c programming forum - http://www.cfanatic.com/topic3908/
     
  3. Rhyton

    Rhyton New Member

    Well thx for the book they or realy realy good . but tbh i got stuck a bit ..
    i was try to use struct to make on employ list see how it's working but !
    Code:
    struct Angajat
    {
            char Name[50];
            int age;
            int telefon;
            char info[80];
    }ang1,ang2;
    So when cin is asking me the name i put in exempla " Enrick Rhyton"
    and hes jumping throw the program like the int is not there in the struct .
    Code:
    Nume angajat :
    Enrick Rhyton
    Varsta angajat :
    Telefon angajat :
    Email angajat :
    
    Nume angjat :
    Enrick
    
    Varsta employee :
    0
    
    Numar employee :
    
    Email address employee :
    
    
    And then i tried like this see what's gonna happen
    Code:
    struct Angajat
    {
    char *name;
    int age;
    int telefon;
    char information[80];
    }
    The out come :
    ./struct
    Nume angajat :
    Enrick Rhyton
    Segmentation fault (core dumped)

    So this means that i actualy exploited my own shit ?(sorry for the language)
    And how can i do make struct to take "firstname and lastname" with out jumping throw my entery program ?
     
  4. xpi0t0s

    xpi0t0s Mentor

    Without the code it's impossible to answer your questions. But remember that char *name declares a variable called name that is a pointer to the real data somewhere else in memory, so if you haven't allocated that memory and pointed name to it that's probably why you get the segfault.
     
    shabbir likes this.
  5. Rhyton

    Rhyton New Member

    well yes you make a point , but what i wanna say it is that every book have hes mistakes and for me to go overthem i need to hit them first .

    And xpi0t0s here is the cod
    Code:
    
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    struct Angajat
    {
            char *name;
            int age;
            int telefon;
            char info[80];
    }ang1,ang2;
    
    int main ()
    {
            Angajat ang1;
    
            cout << "Name angajat : \n" << endl;
            cin >> ang1.name;
            cout << "Varsta angajat : \n" << endl;
            cin >> ang1.age;
            cout << "Celphone angajat : \n" << endl;
            cin >> ang1.telefon;
            cout << "Email angajat : \n" << endl;
            cin >> ang1.info;
    
            ang2=ang1;
    
            cout << endl << "Name angjat : \n" << ang2.nume << endl;
            cout << endl << "Age employee : \n" << ang2.age << endl;
            cout << endl << "Celphone nr employee : \n" << ang2.telefon << endl;
            cout << endl << "Email address employee : \n" << ang2.info << endl;
    
            return 0;
    }
    
     
  6. shabbir

    shabbir Administrator Staff Member

    darbyheribert was a forum spammer and his posts is removed.
     
  7. xpi0t0s

    xpi0t0s Mentor

    The 3rd line of main is exactly what I said.
     

Share This Page