Edit the file using c++ without creating new file

This is a discussion on Edit the file using c++ without creating new file within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by Dante Wingates Ok, ok.. This is like a loop... Is that part of the forum rules? Not ...

  1. #16
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,587
    Quote Originally Posted by Dante Wingates View Post
    Ok, ok.. This is like a loop... Is that part of the forum rules? Not showing C style code to a newbie?
    Is the homework policy part of the forum rules?
    Is pointing out bad things like fflush(stdin) part of the forum rules?

    We who? You're the only one complaining... I said a lot of times I do understand your point, but you cant seem to get what I said a lot of times: I still dont believe that mixing C and C++ makes "bad" code. You believe it is bad, and I do not, so dont mix it... I tried to keep it simple for him and anyone who reads it, and I'll keep trying to keep it simple my way.
    C breaks encapsulation, is error-prone and lacks type-safety.
    All big points that C++ tries to improve.
    So yes, it is bad. It should be thought of as a tool, to be used where it serves your purpose well. In this case, I don't think it does, and you are teaching it to newbies. All in all, you are undermining the point of using C++ in the first place.

    ...C++ programmers can easily read C code.
    Don't be so sure.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #17
    The Autodidact Dante Wingates's Avatar
    Join Date
    Apr 2010
    Location
    Valhalla
    Posts
    56

    Cool

    Quote Originally Posted by Elysia View Post
    Is the homework policy part of the forum rules?
    Is pointing out bad things like fflush(stdin) part of the forum rules?

    C breaks encapsulation, is error-prone and lacks type-safety.
    All big points that C++ tries to improve.
    Some comments before you said "if you show C code to newbies they will think it is the only way to do it", but you're acting like there is exactly one way to do something. Do you realize you're contradicting yourself here? if they cant think there is only one way to do it, you shouldnt be teaching them only one way of thinking. Be careful about what you say, because now it looks more like you just want to have the reason than saying something useful.

    Wikipedia:C++ is designed to directly and comprehensively support multiple programming styles (procedural programming, data abstraction, object-oriented programming, and generic programming), but yet you seem to think of it just as OO. If it is wrong, it would fail to compile. Have you forgotten such freedom because of VC++?

    So yes, it is bad.
    it is indeed? Read what I just said. If it is, the language itself is wrong, because it was designed with such freedom in mind. And as you said early, it is bad by a purists point of view, do I look like one? Have ever heard that truth is not absolute? So dont go around thinking that your point of view is the right one.

    [i]It should be thought of as a tool, to be used where it serves your purpose well. In this case, I don't think it does, and you are teaching it to newbies. All in all, you are undermining the point of using C++ in the first place.
    Exactly! you dont think it does! But what if I do? It does as long as it serves its purpose. So nice that we finally agreed on something, eh? Im the one teaching, so I'll teach him how to be free, not how to think only one way. One of the points of using C++ is freedom, and you should know that. You teach him your way, and I do it mine.

    Don't be so sure.
    Why cant I be so sure of something as you can?

    One thing impresses me...

    C breaks encapsulation, is error-prone and lacks type-safety.
    I never thought I would heard/read such a thing from a C++ programmer... If you're so afraid of errors, then I believe you should work with something like Java because it is exactly that kind of language: it belives the programmer is dumb and wont give him freedom to do whatever he wants just because it may be risky and unsafe.

    Brasil 3 x 0 Chile
    Last edited by Dante Wingates; 06-28-2010 at 10:47 PM.

  3. #18
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,587
    Quote Originally Posted by Dante Wingates View Post
    Some comments before you said "if you show C code to newbies they will think it is the only way to do it", but you're acting like there is exactly one way to do something. Do you realize you're contradicting yourself here? if they cant think there is only one way to do it, you shouldnt be teaching them only one way of thinking. Be careful about what you say, because now it looks more like you just want to have the reason than saying something useful.
    Oops. Well, contradiction is bad.
    But the thing is, you shouldn't teach them the wrong way, as you certainly are.
    As you say, there are other ways.

    Wikipedia:C++ is designed to directly and comprehensively support multiple programming styles (procedural programming, data abstraction, object-oriented programming, and generic programming), but yet you seem to think of it just as OO. If it is wrong, it would fail to compile. Have you forgotten such freedom because of VC++?
    The compiler has nothing to do with it.

    it is indeed? Read what I just said. If it is, the language itself is wrong, because it was designed with such freedom in mind. And as you said early, it is bad by a purists point of view, do I look like one? Have ever heard that truth is not absolute? So dont go around thinking that your point of view is the right one.
    No. Like everything out there, the language is a collection of tools. You must use them wisely. I cannot be blamed if you cut your leg with a chainsaw. After all, it was made to cut things. C++ is similar.
    The analogy here is that you are cutting your leg with the chainsaw.

    Exactly! you dont think it does! But what if I do? It does as long as it serves its purpose. So nice that we finally agreed on something, eh? Im the one teaching, so I'll teach him how to be free, not how to think only one way. One of the points of using C++ is freedom, and you should know that. You teach him your way, and I do it mine.
    Freedom can mean a lot of things. You are correct in that you are allowed to teach them in the way you want.
    You are not correct in teaching them to break fundamental principles the language builds on.

    Why cant I be so sure of something as you can?
    I say that because I am not sure myself.

    I never thought I would heard/read such a thing from a C++ programmer... If you're so afraid of errors, then I believe you should work with something like Java because it is exactly that kind of language: it belives the programmer is dumb and wont give him freedom to do whatever he wants just because it may be risky and unsafe.
    I don't want tools to hold my hand. I want people to use tools right, which you cannot seem to understand.
    The thing about safety is that it decreases bugs and maintenance costs. The former is good for you as a freelance programmer, the latter is good for companies.
    C also brings a lot of security issues. You can avoid those completely by using pure C++ code. That's good for everyone.

    Using C code inside C++ has its purpose, and it is fine. When used correctly.
    Like you said before, implementing a string class. When you do that, you must most certainly use some C constructs. And that is perfectly fine and reasonable. But you should also overload the stream operators to provide abstraction.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #19
    In the Land of Diddly-Doo g4j31a5's Avatar
    Join Date
    Jul 2006
    Posts
    476
    Ok, while I enjoy the brainstorm of the two of you, it has made this thread deviate from its intended purpose. And I think the poster is intimidated and confused by the two of you. Can we please move to the initial issue here? Or can you guys just make a different thread for this please? Thanks.
    ERROR: Brain not found. Please insert a new brain!

    “Do nothing which is of no use.” - Miyamoto Musashi.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory Leak in AppWizard-Generated Code
    By jrohde in forum Windows Programming
    Replies: 4
    Last Post: 05-19-2010, 04:24 PM
  2. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  3. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  4. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21