Thread: Problem in concatenation of arrays

  1. #31
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by SirPrattlepod View Post
    If I think their example is wrong why would I follow?
    because this community has clear rules, standards, and expectations of its members. if you can't follow them, then you will have a very hard time here.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  2. #32
    11DE784A SirPrattlepod's Avatar
    Join Date
    Aug 2013
    Posts
    485
    Quote Originally Posted by Elkvis View Post
    because this community has clear rules, standards, and expectations of its members. if you can't follow them, then you will have a very hard time here.
    So be it. If that's what it takes to improve the quality of responses then *shrug*

  3. #33
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    Quote Originally Posted by SirPrattlepod View Post
    I disagree strongly. The thread was going nowhere. I could have given a response in pseudocode I guess, or given subtle hints, or other crazy stuff, but at the end of the day writing it in code is equivalent. In my defence my "answer" is the same as if I'd given an English description, a mathematical description, a pseudocode description, or whatever.
    It is quite true that this topic was going nowhere. But that was because the OP was waiting for someone to fix the program for him. He appears to be unwilling to do the actual work himself but continues to cry and cry until someone takes pity on him and gives him a solution. His tactics seem to be working, congratulations.

    Jim

  4. #34
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    In my defence my "answer" is the same as if I'd given an English description, a mathematical description, a pseudocode description, or whatever.
    It certainly is not. Had a description of the solution been given in english it would have been up to the OP to translate this into C++, which is a required skill if he hopes to ever become proficient in _any_ programming language. By providing the code straight up you have robbed him of the opportunity to practice this.

    Furthermore as Elysia has attempted to point out several times now, using dynamically allocated C-style arrays is not the proper way to solve this problem. Since OP has failed to explain why this is a requirement it is at this point fairly safe to assume that there is no good reason for this. By supplying this code to the OP you've made sure there is no immediate incentive for him to learn how to solve this using std::vector. Did you not just denounce schools teaching students to use old C-style mechanics when writing C++? Well you have now (inadvertently perhaps) done the same thing.
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  5. #35
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by SirPrattlepod View Post
    I disagree strongly. The thread was going nowhere. I could have given a response in pseudocode I guess, or given subtle hints, or other crazy stuff, but at the end of the day writing it in code is equivalent. In my defence my "answer" is the same as if I'd given an English description, a mathematical description, a pseudocode description, or whatever.
    You could have worked with the OP on lower levels: ie, how to use vectors, how to add items, how to sort, whatever. Feeding a complete working example, working or not, is usually the wrong way.
    Not to mention, what you gave was subpar C++ code. I'd go as far as call it C code, even.
    There are two things we should strive for: teach newbies to be good programmers (ie, guide them to the answer; let them experiment, fail and learn) and teach them how to write high quality, safe, portable C++ code.
    You failed on both accounts.

    It's not inaccurate. They (Elysia) attacked me by saying my previous answers were non-constructive. They implied that I was saying the OPs code was crap (which I never did). I then added, what... 8?, lines plus a few comments to the OPs source code and then Elysia insulted the OP by saying their source code was complete and utter rubbish? Something doesn't add up here. I don't care if Elysia has 1 post or a million posts I'll be honest every time, even if the honesty seems brutal. Live with it.
    Let me clear up some stuff.
    I agree that the OP's code is garbage, but your previous replies didn't add anything of value.
    Heard of constructive criticism? Yeah, we fail on this sometimes as we're not perfect, but try to learn from it. Feel free to criticize code, but try to also help in some way, like "X is garbage. But that's okay, you can do Y to fix it."
    And yes, your additions to the code is also garbage, because not only did you use the OP's bad code, you also added more bad code to it. Not a very good thing to do. It would have been much better if you'd modified it to use safer and modern C++ idoms such as vectors in your examples.

    To be honest I'm not overly impressed with "the regulars" and their conduct. Should I quiver in fear and follow like a lost lamb? Nah. Of course not. How new I am or how "old" they are is not relevant. If I think their example is wrong I'll say so and not just bow to their experience... that'd be a bit silly.

    Edit: I do realise your post was written with the best of intentions and I thank you for that. But, please, do not suggest to me how I should conduct myself.
    Opinions are important and you should absolutely not "succumb" to someone else. It's good that you express your opinions, but at the same time, we like to get along.
    Generally, there is one thing that is frowned upon and that is spoon-feeding. If you spoon-feed people, members here will disagree with you, and that's never a good thing.
    We want to get along with you. I don't care if you're a new member or an old member. It's all the same. You are as welcome to this board as anyone else. All we ask you to do is not spoon-feed people.
    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.

  6. #36
    11DE784A SirPrattlepod's Avatar
    Join Date
    Aug 2013
    Posts
    485
    vectors are not lower level; they're higher level!

  7. #37
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by SirPrattlepod View Post
    vectors are not lower level; they're higher level!
    what does that have to do with anything?
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  8. #38
    Registered User
    Join Date
    Jul 2013
    Posts
    158
    Quote Originally Posted by Elysia View Post
    Then I am going to suggest you rewrite your program using vectors. It will be good learning experience
    I studied vectors and now my same programm using them:
    Code:
    // crcvectors.cpp : Defines the entry point for the console application.
    //
    
    
    #include "stdafx.h"
    #include<iostream>
    #include<conio.h>
    #include<cctype>
    #include<vector>
    using namespace std;
    
    
    int main()
    {
        int n,lim_fcs,lim_pattern,tot_size,len;
        cout<<"\nEnter the length of message\n";
        cin>>n;
        vector<int>message(n);
        
        
        vector<int>::iterator p; 
        
    
    
        cout<<"\nEnter the message\n";
    
    
        for(p=message.begin();p!=message.end();p++)
        {
        
        cin>>*p;
        }
    
    
        cout<<"\nThe message is:\n";
        for(int i=0;i<message.size();i++)
    
    
        {
        
            cout<<message.at(i);
            cout<" ";
        }
        //storing here to retrieve it later for xor
        vector<int>message1(n);
    
    
        for(int i=0;i<message.size();i++)
        {
            message1.at(i)=message.at(i);
        }
         cout<<endl;
        cout<<"Enter the Limit for fcs(frame check sequence)"<<endl;
        cin>>lim_fcs;
        cout<<endl;
        cout<<"Enter the size for Pattern vector"<<endl;
        cin>>lim_pattern;
        vector<int>pattern(lim_pattern);
        vector<int>::iterator q;
        cout<<"Enter the Pattern"<<endl;
        for(q=pattern.begin();q!=pattern.end();q++)
        {
        cin>>*q;
    
    
        }
    
    
        cout<<"The pattern you entered is:"<<endl;
    
    
        for(int j=0;j<pattern.size();j++)
        {
            cout<<pattern.at(j);
            cout<<" ";
        
        }
        cout<<endl;
        tot_size=n+lim_fcs;
    
    
        len=tot_size-n;
        vector<int>a(len,(int)0);
        //for(int j=0;j<len;j++)
        //{
            //cout<<a.at(j);
            //cout<<" ";
        //}
        for(int j=0;j<len;j++)
        {
        message.push_back(a[j]);
        }
    
    
        cout<<"The new Message is :"<<endl;
        for(int k=0;k<tot_size;k++)
        {
        cout<<message.at(k) ;
        cout<<" ";
        }
        cout<<endl;
        vector<int>result(tot_size);
        for(int k=0;k<len;k++)
        
            result.at(k)=message.at(k)^pattern.at(k);
    
    
        cout<<"result is:"<<endl;
        for(int k=0;k<len;k++)
        
            cout<<result.at(k)<<"\t";
        cout<<endl;
        for(int k=0;k<len;k++)
            message1.push_back(result.at(k));
            cout<<"The message to send(at sender side is)"<<endl;// the message ready to be sent 
        for(int index=0;index<tot_size;index++)
         {
               cout<<message1.at(index);
              cout<<" ";
          }
            cout<<endl;
        
        getch();
        return 0;
    }

  9. #39
    Registered User
    Join Date
    Jul 2013
    Posts
    158
    Quote Originally Posted by jimblumberg View Post
    It is quite true that this topic was going nowhere. But that was because the OP was waiting for someone to fix the program for him. He appears to be unwilling to do the actual work himself but continues to cry and cry until someone takes pity on him and gives him a solution. His tactics seem to be working, congratulations.

    Jim

    The OP has done it now using vectors...You have no right to say what you said..I don't care for guys like you who roams about in search of just cross posters..If SirPrattlepod did give me a very close hint one should not overreact over it...If you canna help others just stop and dont stop others from helping.

  10. #40
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    SirPrattlepod did gave you a hint, albeit a very, very wrong one, which is why everyone is reacting. We don't want you to solve the problem YOUR way. We want you to solve it using OUR way, because we know good from bad practice and we want you make you a GOOD programmer and not a bad one.
    Your code has horrible indentation, however, so it's difficult to read. You should work on improving that.
    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.

  11. #41
    Registered User
    Join Date
    Jul 2013
    Posts
    158
    Your code has horrible indentation, however, so it's difficult to read. You should work on improving that.[/QUOTE]

    Actually what i posted earlier and many of you called it CRAP that's so painful for me.this is a forum comprising of programmers of various skills ...some maybe just developing others maybe professionals .calling one's code such slangs should be revived..that's not fair in simple words..you did tell me to use vectors instead that;s good idea i learnt them and used them but as before i posted code as i wrote it (raw form)..i was not presenting it rather sharing it as usual.this i does because earlier too i posted code as on its way to completion not fianlly ..that's why i didn't care for indentation

  12. #42
    11DE784A SirPrattlepod's Avatar
    Join Date
    Aug 2013
    Posts
    485
    Quote Originally Posted by Elysia View Post
    SirPrattlepod did gave you a hint, albeit a very, very wrong one, which is why everyone is reacting. We don't want you to solve the problem YOUR way. We want you to solve it using OUR way, because we know good from bad practice and we want you make you a GOOD programmer and not a bad one.
    Your code has horrible indentation, however, so it's difficult to read. You should work on improving that.
    Indentation is nothing.

    My solution is not "wrong". In fact, my contributions give more insight into what is happening than using vectors can ever hope to do.

    Telling someone to solve a problem YOUR way instead of THEIR way is, well... have you heard of the word hubris?

    Quote Originally Posted by jeedi khan View Post
    Your code has horrible indentation, however, so it's difficult to read. You should work on improving that.
    Actually what i posted earlier and many of you called it CRAP that's so painful for me.this is a forum comprising of programmers of various skills ...some maybe just developing others maybe professionals .calling one's code such slangs should be revived..that's not fair in simple words..you did tell me to use vectors instead that;s good idea i learnt them and used them but as before i posted code as i wrote it (raw form)..i was not presenting it rather sharing it as usual.this i does because earlier too i posted code as on its way to completion not fianlly ..that's why i didn't care for indentation
    Mate, just ignore them. I didn't call your code crap (although, honestly it could be improved a lot ;-)), Elysia did.
    Last edited by SirPrattlepod; 08-21-2013 at 08:38 AM.

  13. #43
    11DE784A SirPrattlepod's Avatar
    Join Date
    Aug 2013
    Posts
    485
    Elysia, please point out how my hint is "very, very wrong". Thanks.

  14. #44
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Quote Originally Posted by SirPrattlepod View Post
    Indentation is nothing.
    Care to qualify this statement?

  15. #45
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by SirPrattlepod View Post
    Indentation is nothing.

    My solution is not "wrong". In fact, my contributions give more insight into what is happening than using vectors can ever hope to do.

    Telling someone to solve a problem YOUR way instead of THEIR way is, well... have you heard of the word hubris?
    Indentation is everything.
    The solution is not wrong, but is certainly isn't good. It contains bad practice all over the place.
    Hubris? No, but I googled it. But come, don't be silly. If newbies solved their problems their way, what would we end up with? We are the ones who know the language. We know what's good, we know what's bad, so what is wrong in guiding people to solving it our way? Our way simply can simply mean getting rid of bad practice. I think you are misunderstanding what I meant by it. By posting a solution, you did, in fact, solve it your way, in the way you think the OP should solve the problem. In this sense, we're the same. We guide the newbies to solving the problem by giving input, essentially making it so they do it the way we want.

    Mate, just ignore them. I didn't call your code crap (although, honestly it could be improved a lot ;-)), Elysia did.
    Quote Originally Posted by SirPrattlepod View Post
    Elysia, please point out how my hint is "very, very wrong". Thanks.
    After you just told someone to "ignore" me?
    I think you have to work on your manners. Even I have limits to my patience and I tend to treat people as innocent until proven guilty.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. K&R problem !! String concatenation :(
    By karanmitra in forum C Programming
    Replies: 9
    Last Post: 08-18-2005, 05:20 AM
  2. printing arrays with concatenation
    By derek23 in forum C Programming
    Replies: 1
    Last Post: 07-17-2005, 03:02 AM
  3. concatenation
    By rose2626 in forum C++ Programming
    Replies: 10
    Last Post: 04-25-2003, 01:27 PM
  4. concatenation
    By F*SH in forum C++ Programming
    Replies: 34
    Last Post: 11-13-2002, 06:47 PM
  5. Concatenation in C++
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 12-05-2001, 01:05 PM