[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Anyone here know C++?
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 35
Thread images: 2
File: fucking code.png (149 KB, 1920x1080) Image search: [Google]
fucking code.png
149 KB, 1920x1080
I'm having some trouble with the final assignment for my C++ course, was wondering if anybody on this board could help me out.

string encode(string code,string message)
{
string::size_type j;
string alphabet = "abcdefghijklmnopqrstuvwxyz", temp;
int i = 0;

for(i=0;i<=message.length();i++){
j = alphabet.find(message[i],0);
temp = code[j];
message.replace(i,1,temp);
}

cout << "The encoded message is: " << message << endl;
return message;
}

This is the current problematic part of my code, as is. The goal of the program is to encode messages, as I hope is obvious. The other problem that I have is that I need to treat upper case and lower case characters as though they're the same, and I'm not sure how to do this, either. Anybody able to help me out?
>>
File: ass.gif (2 MB, 170x238) Image search: [Google]
ass.gif
2 MB, 170x238
Bump? :(
>>
>>52005078
Please save your professor the misery of having to look at/grade this and just drop out. C.S. is obviously not the thing for you.
>>
>>52005078
Fucking hell Josh that looks like shit. I'm a pretty shit C++ programmer myself but I'll try to help.
>>
>>52005161
>bumps with nigger-tier asses
changes majors script-kiddie. thinking critically is not for you.
>>
> I need to treat upper case and lower case characters as though they're the same
use
::tolower()
?
>>
>>52005269
I've only been at it for like two months, I've never coded at all before. And it's my last assignment of the semester and I didn't plan on majoring in Computer Science anyway, I just wanted to give the class a shot.
>>
OP: Please fuck off and solve your own assignments. The basic idea of assignments is to teach you by having you actually use the language rather than having people spell it out for you.

A few years ago we had some first year CS faggot show up and ask us to solve some of his assignments and after some idiot solved them all for him and did a good job at it we had lazy first year CS students practically swarm the board asking for us to solve their first year programming course assignments for them.

So fuck off and nobody help him. He's supposed to figure it out himself. If he can't, then he obviously shouldn't be in CS.
>>
>>52005364
How? We weren't taught this. What would the proper syntax/parameters be?
>>
>>52005078
>not using emacs primary ide
>>
>>52005412
I've done all of my assignments in my class up to this one on my own and have aced all of my exams and have A's on all of my previous assignments. This is the first time I've ever come to any internet site asking for help, and it's because I'm genuinely perplexed. And as I said, C.S. isn't my major anyway, I just took the class for a few credits and out of a slight interest. Fucking excuse me. By your logic, tutoring should be outlawed.
>>
>>52005444
string ayy = "LMAO";
cout << ayy.tolower() << endl;
// prints "lmao"


t. java programmer
>>
>>52005412
>The basic idea of assignments is to teach you by having you actually use the language rather than having people spell it out for you.
This is debatable. Really, the idea of an assignment is to review the knowledge that one is taught through lectures, readings, etc. The assignments are practice. If OP wasn't taught enough to efficiently complete the assignment, why can't he seek help? Furthermore, if one is programming as a career, they're most likely working on apart of a team that helps each other debug and what have you.
>>
>>52005505

My bad, I must have gone to the wrong board. I thought I was on the technology board but apparently this is the "do my fucking homework because I'm literally retarded" board.
>>
>>52005505
If you can't solve this, then you probably should just drop those electives and pick up something else. Maybe from the Women's Studies program or something equally well suited for the mentally challenged.
>>
>>52005576
How is asking for help on an assignment that I'd done a bulk of asking people to "do my fucking homework"? I'm nearly done with this program, I'm literally just asking for help because I'm not getting the expected output and as a non-C.S.-major in an intro-level course, I don't understand why. All I want is some help and an explanation to better my understanding from someone who is hopefully more knowledgeable than myself, I don't want the answer explained and given to me like a fucking toddler on the spectrum.
>>
>>52005078
Post the actual assignment so I know how the fuck youre supposed to do that encoding
>>
>>52005616
>A non-Computer Science major in an Intro-level course can't see this solution as obviously as someone else who has much more experience in the language?
>He must be mentally challenged.
>>
>>52005645
Put the whole thing on pastebin so we can see what you're doing.

Then we'll have a chance to help, maybe.

Also, use better butts in the future.
>>
>>52005681
Basically, the infile has keywords and then, a message. For example, the first keyword is "Computer." What my program currently does is read in the keyword, delete the letters from said keyword from the alphabet string, and then slap the keyword at the beginning, so my "code" is computerabdfghijklnqrsuvwxyz." Then, I'm supposed to read in the message (let's say that the message is "OP is a faggot"). It would take each letter, find the position of that letter in the alphabet string, and then look at the same position in the code string and replace the letter in the message with the equivalent letter from the code.
>>
>>52005723
http://pastebin.com/TRc5ni5E

Thank you for the calmness. The assignment is pasted at the bottom. Though I don't want help completely finishing it, I'm just curious as to why my program stops working after the getline. The encoding function causes the program to crash when I build and run it, which is what I don't understand.
>>
>>52005078
>for(i=0;i<=message.length();i++)
This is a segfault waiting to happen.
>>
>>52005778
It's also worth mentioning that I'd tried to do the encoding function several different ways, and I've gotten similar erroneous results - that's the only reason I came to a board asking for help, because I've attempted every method we've been taught, with the same syntax my professor (a 78 year old man, mind you) taught it to us with, and I continue to get program crashes.
>>
>>52005778
do i understand it correctly that it should switch a letter with its position in the alphabet?

so c is in pos1, supposed to switch with pos3,
o is in pos2, supposed to switch with pos15 and so on?

seems like one hell of a mess.

try std::swap(str[i],str[j]);
>>
>>52005958
Yes, you are correct.
>>
>>52005682
>Does intro course
>Can't figure out intro course assignment work
You'd have a point if this was a more advanced course, but it's an intro course. It's not supposed to require previous knowledge to complete.

If you can't complete an intro course in a subject, then said subject probably isn't for you and you should instead to stick to what you're good at.
>>
>>52006030
I'm not objecting and saying that this is for me, I don't disagree that it isn't. But I do need to complete the class, I'm just a bit stuck on this last assignment.
>>
>>52005958
Please stop giving him more advice... Last time we did intro course assignments for some lazy asshole other lazy assholes kept coming here for months asking us to do their assignments for them.
>>
>>52006057
If you can't complete it on your own like you're supposed to, then why should you be able to get the credits for the course?

There's a reason why people who get caught for plagiarism have the assignments or even thesis declared invalid due to it.
>>
>>52006111
Like I said before, by this same string of logic, if a student goes to a tutor for help editing a essay, why should they be able to hand that essay in and get credit for it? And like I also said earlier, I've done all the other course work and aced all the exams I've taken single-handedly. Why would I no longer deserve credits for all of that work when all I need is some help and clarification on a small portion of this last assignment? Realistically, I could neglect to hand this assignment in and still pass the course with my current grades. I want to complete the assignment and I'm getting help not just to finish the work but to better understand what it is I did wrong, and better understand the language as a whole.
>>
>>52006066
You realize that if I came here asking for help not knowing of this previous incident that you're referring to, but just knowing that /g/ is a technology board that exists, that people coming on and asking for help is an inevitability?
>>
>>52006183
Do you intend for message to be getting shorter with every iteration of the loop in the encode method?

Check your bounds, too - as pointed out by this guy:
>>52005802
>>
>>52006353
Each message only goes through it once, there are several keywords and messages in the infile.
>>
I'd help you OP but I don't know what the fuck you're trying to do
>>
>>52006474
It's in the bottom of the pastebin I posted here:
>>52005778
Thread replies: 35
Thread images: 2

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.