[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
How do I do this? It's the last project I'm working
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: 34
Thread images: 5
File: 114905921.png (13 KB, 597x123) Image search: [Google]
114905921.png
13 KB, 597x123
How do I do this?

It's the last project I'm working on for a class, it's C++.
>>
I only know how to edit config files for my desktop desu
>>
I only know how to helloworld.exe
>>
>>51743158
your going to have to use a dynamic string array to be resized every time it reads a new string (make a function out of it)
make a variable to count the total number of strings
then use that variable to make your loops for each question
>>
>>51743158
do you have an example of the LIST.txt file?
>>
>>51743363

https://gist.github.com/anonymous/3d1eb71d2f3ebd6d4bf8
>>
File: hacker named 4chan.jpg (100 KB, 800x800) Image search: [Google]
hacker named 4chan.jpg
100 KB, 800x800
are you literally to stupid to stupid to perform basic tasks?

create a 2d array thats 'big enough';
'open' the file.
read the file into a buffer until you get a newline character.
put the string in the array.
iterate over array and its strings (they are just char arrays)
simply compare chars
and do what you want next.

God you are hopeless.
I hope you fail hard.
>>
I don't know C++ but if it's anything like C
Malloc/realloc for array of array of chars. Qsort for sorting. Strstr for spaces or A
>>
>>51743700

>you're retarded because you're in an intro class for programming

oh man, i didn't realize.
>>
>>51743232
me to xD i3 4 lyf
>>
Use libraries and tell them to fuck off.
>>
>>51743766
to be fair if they haven't taught you this shit, the school is retarded, if they have and you can't work it out, you're retarded
>>
>>51743158
Since they didn't ask you to ``print EACH of the following'', i would take the concepts/strings from LIST.txt and store them into ``and'' array of strings and print the following:
All the concepts from the array in alphabetical order that contain spaces, the letter A ( small of large caps ) and that start with a consonant.
>>
>>51743854

it's an online class, they aren't teaching me anything. i'm actually paying to read my own book.
>>
>>51743872
No, you're paying to get credits.
>>
>>51743892

regardless i am still teaching myself.
>>
>>51743948
You're always teaching yourself, silly nigger.
>>
Google can solve most of this, what you are probably missing is what you should google.

Figure out how to read a text file into a dynamic string array.

Figure out how to order a string array in alphabetical order.

Figure out how to see if a string contains a whitespace.

Figure out how to see if a string contains a letter (hint, it's similar to whitespace, don't forget to check for upper and lower case).

Last one your might be able to do with some library function I don't know about, but it is also similar to the above two. A string starts with a consonant if it is in the character index value of a-z and it is not a vowel.


Bit of advice for the future, if you are planning to program for a living, you have a lot of work to do. This is very trivial stuff that most people here were doing in middle school. Maybe you already know that though.
>>
File: 1412202832458.gif (381 KB, 260x317) Image search: [Google]
1412202832458.gif
381 KB, 260x317
>>51743965
>>
>>51743158
http://www.cplusplus.com/reference/algorithm/sort/
http://www.cplusplus.com/reference/string/string/

You're welcome. C++ libraries are really nice, at least compared to doing it the hard way in C. You don't even have to use the string functions if you want to just write functions that checks a string for spaces, letters etc.
>>
>>51743970

I'm not, don't worry lol. I'm a conceptual designer, I never wanted to touch this stuff but they are forcing me to take it "for muh program".
>>
File: 1448148134574.jpg (58 KB, 540x531) Image search: [Google]
1448148134574.jpg
58 KB, 540x531
>>51744012
>>51743970
>>51743346

ty anons
>>
>>51743700
>>51743707

C++ has iostreams. You don't even have to worry about buffer allocation.

    #include <sstream>
#include <iostream>
#include <string>
#include <fstream>
....

std::ifstream fs(file.c_str());
std::string line;

if (!fs.good())
{
printf("panic");
}

while (std::getline(fs, line))
{
// Process line
}



You may not even need all those includes. I'm doing other stuff in the program I pulled that from.
>>
>>51744103
iostream is the only one we've been using so far.
>>
>>51744158
and this is your final project?

What the fuck, family.
>>
>>51744175
Seems doable. My final project for my first coding class was to program boggle with recursive search and we only knew scanner
>>
>>51744198
>Seems doable.

No shit, it's like 2nd week shit.

I'm pretty sure anon just didn't pay any attention in class.
>>
>>51744226
He said it was online. But yeah, it seems easy enough.
>>
>>51744175
we only had 5, it was a fast track course

>>51744226
see
>>51743995
>>
>>51743965
I agree with you entirely except on the terminology. What he's doing is called learning. He can't teach himself something he doesn't know, to be succint. He can learn something new, though.
>>
Wow this is just
>how to read strings
>how to array/struct/if/for
>how to regular expression

>no algorithmic restriction
>no hardware restriction
>no OO or custom types
>easy mode
>>
File: 1439233844018.jpg (135 KB, 854x800) Image search: [Google]
1439233844018.jpg
135 KB, 854x800
>>51744892

ez for you
>>
this is what i have so far, i just started writing it out pls help

https://gist.github.com/anonymous/844dd113fcceefb53251
>>
>>51745004

ew what was i doing

https://gist.github.com/anonymous/ddc44f27fdd930e619e0
Thread replies: 34
Thread images: 5

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.