C/C++ guide me

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

  1. Rhyton

    Rhyton New Member

    Joined:
    Jun 23, 2013
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    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

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    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

    Joined:
    Jun 23, 2013
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    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

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    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

    Joined:
    Jun 23, 2013
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    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

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    darbyheribert was a forum spammer and his posts is removed.
     
  7. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    The 3rd line of main is exactly what I said.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice