Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   C/C++ guide me (http://www.go4expert.com/forums/c-cpp-guide-t29707/)

Rhyton 26Jun2013 00:45

C/C++ guide me
 
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)

shabbir 26Jun2013 10:08

Re: C/C++ guide me
 
Quote:

Originally Posted by Rhyton (Post 99723)
if i know php in a medium way how hard can it be to learn c/c++ ?

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.
Quote:

Originally Posted by Rhyton (Post 99723)
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 ?

Depends on how you have manipulated the data but normally it is the case that there is equivalent function in almost all programming language.
Quote:

Originally Posted by Rhyton (Post 99723)
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?

Check out the thread I have in other c programming forum - http://www.cfanatic.com/topic3908/

Rhyton 28Jun2013 03:02

Re: C/C++ guide me
 
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 ?

xpi0t0s 28Jun2013 05:03

Re: C/C++ guide me
 
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.

Rhyton 28Jun2013 11:27

Re: C/C++ guide me
 
Quote:

Originally Posted by darbyheribert
Learn C++ Programming with an extensive tutorial. ... Free C / C++ / C# Newsletter! Sign Up ... Plus you can ask on the forums or email me if you get stuck.

best nanny cam
nanny cam online

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;
}


shabbir 28Jun2013 12:06

Re: C/C++ guide me
 
darbyheribert was a forum spammer and his posts is removed.

xpi0t0s 28Jun2013 15:49

Re: C/C++ guide me
 
The 3rd line of main is exactly what I said.


All times are GMT +5.5. The time now is 03:23.