In C++ you have this:
std::string = "Name";
You can also read file with it, unlike reading the contents into a char[] with a limited amount of memory.
So whats is C equivalent of a C++ string?
In C++ you have this:
std::string = "Name";
You can also read file with it, unlike reading the contents into a char[] with a limited amount of memory.
So whats is C equivalent of a C++ string?
So whats is C equivalent of a C++ string?
There isn't one. You could go out and find a third party string library like bstring, but unlike std::string, you don't have the option of a standard string "class" in C.
The closest is a character array:
char *name = "Jody"; // create a pointer pointing to the name of 5 chars
char name2[] = "Mary"; // create an array of 5 chars to hold the name
char name3[20]= "Janine"; // create an array of 20 chars to hold the name
Since they are character array 'strings' they all end in '\0' designating the end of string
That makes C a bit odd. It would be hard to read a file if you dont know the size. you could use malloc(); To expand the size of the char[]. Then it also probally would have to be a pointer char[];
Seems like you have allot of experience in C and C++.
I am trying to find a programming language that is right for me.(Trust me i know how weird that sounds).
I am currently programming in C++, and rather good at it.
In your opinion what is a better language. C or C++.
I mean this for operating systems to embedded software, deivce drivers, games and networking.
Networking like server - client side programs?
And is C++ so called OOP really going to be a bigger hit then C?
It would be hard to read a file if you dont know the size.
Well, it's not a one-liner, but not unusually difficult. I don't disagree that this is a sticking point, but even C++ isn't a good language for string processing. C is even worse at it.
I am trying to find a programming language that is right for me.(Trust me i know how weird that sounds).
That doesn't sound weird at all. I've experimented with some obscure languages in my time. ;)
In your opinion what is a better language. C or C++.
C, no contest. C++ has a few niceties that I miss when working with C (std::string being one of them), but it also has a heaping pile of doo-doo that I don't miss. So the simplicity and elegance of C is a net win, in my opinion.
And is C++ so called OOP really going to be a bigger hit then C?
C++ is already a bigger hit than C, mostly because it makes for cleaner modeling of large systems.
Aaa yea i am trying C now. I also get a weee bit stucked with string processing. C is very eligant and simple. Seing how difficult it is with C++ all the advance words and libraries and stuff like that, it sometimes takes the fun out of programming. Strange i run into more errors with C++ than C.
But hey thanks for the help... Have a nice day/night.
Strange i run into more errors with C++ than C.
C is an older language, but c++ is a much stricter language. There are lots of things that you can get away with in C that you can't in c++, and C will let you hang yourself a lot faster. Although c++ is derived from C a C program will probably not compile with a c++ compiler without making some changes.
In your opinion what is a better language. C or C++.
It is highly dependent on what you do. C can certainly be simpler and hassle-free when doing some simple tasks (or low-level tasks). But C rapidly becomes difficult to manage on larger applications. I love software engineering, and C++ is awesome for that.
I mean this for operating systems to embedded software, deivce drivers, games and networking.
It is mostly a matter of size and complexity of the system. Embedded software and device drivers are usually very small programs and require quite a bit of low-level tricks (bit-wise operations, and setting hardware registers and interrupts), so, C is definitely the way to go (often the only choice, aside from assembly). Games and networking is almost entirely in C++ because these kinds of software are much more complicated structurally and require the kind of higher-level constructs that C++ allows you to do, but there are also other high-level languages used in those fields (interpreted or scripting languages, like C#/Java, PHP, Python, etc.). Operating systems (and compilers) are a bit of an exception here, most of them are entirely written in C (with some assembly), but these are large and complex systems that probably ought to be programmed in C++ (still, with many low-level components in C), but these are also very old and robust systems that cannot be changed overnight.
And is C++ so called OOP really going to be a bigger hit then C?
How many times will I have to repeat this: C++ is not an object-oriented programming language! It is a multi-paradigm language, OOP is just one of many paradigms used in C++. Anyways, there is no question that OOP is a bigger hit than procedural programming (the prevalent paradigm in C). The reasons for that are too many to enumerate. In any case, it is no reason to forget procedural programming, and in fact, the two are not mutually exclusive by any means. I mix these two paradigms (and a few more) on a daily basis. One doesn't superseed the other, they complement each other, and that is true of all programming paradigms, and that's another reason why I like C++ so much, because it embraces that complementarity of paradigms.
I also get a weee bit stucked with string processing.
Weirdly enough, I sometimes find C's string processing cleaner, at least for simple stuff, not full-blown grammer parsers and all that. But I tend to use C++ style just to be consistent.
Seing how difficult it is with C++ all the advance words and libraries and stuff like that, it sometimes takes the fun out of programming. Strange i run into more errors with C++ than C.
That's not surprising at all. C++ is vastly more complex than C, with more keywords, more features, more rules (e.g., overloading), more constructs, more library features, and even a second complete programming language within the C++ language (I'm talking about template meta-programming, of course). It takes much longer to master, but it is undeniably much more powerful too. Additionally, C++ is much stricter at compile-time than C is, the idea with this is to get as much robustness as possible without compromising run-time performance, and it does so with stricter compilation rules. At first, it can be annoying to get all these errors all the time, but with time, you learn to make friends with the compiler and turn these strict rules to your advantage (in much of my own coding in C++, 90-95% of the "debugging" work is getting the code to compile correctly, once it compiles, it usually runs without error right away).
many times will I have to repeat this: C++ is not anHow object-oriented programming language!
I know it isnt an object-oriented programming language. But it does have The
class MyClass
Thing that sure as hell makes things esier to code large projects... That just seem to atract more people.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.