• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

diaspora

Member
Try printing the variables $usnm and $pass and sandwich them between <p> tags so you can see right on the page if they're being passed through when you submit the HTML form.

Fairly standard debugging here. Make sure what you expect to happen is exactly what you see happening.

Thanks yo, this helped me nail it. I think I've cleared everything.
 
How can I get the DATE field to dd/MM/yyyy format?

I tried putting
Code:
SELECT convert(varchar,BookingDate, 103) AS DATE,
but this never worked either.
You don't want to SELECT here, that performs a query on the database. Think "read", not "write".

You want to UPDATE the table if you want to change any of its existing values.

Unfortunately, the MSDN documentation for UPDATE is pretty nasty to read and it lacks the rail graphs of SQLite's docs; you should take a look at that even though MS's SQL is different in many of its details. The UPDATE statement has this form;
Code:
UPDATE [table name] SET [column name] = [operation you're trying to do]
Plus a number of additional parameters if you want to perform the same operation on multiple columns at once, and filter by criteria.
 
Anybody familiar with Android? I'm working in Android Studio on a really simple app. It's basically just opening a webpage when I launch the application.

I'm having a problem where the webpage opens before I even click on the app icon. On the emulator, as soon as I unlock the phone, the webpage loads. On my phone, when I unlock it, I see a blank browser tab.

Here's what my onCreate() and onStart() code looks like, assuming the culprit is one of these. I am very, very new to this so I am probably overlooking something that shouldn't be there.

This is just a single class project, so the only other code is the code generated by Android Studio and the openWebPage() method I wrote, but I don't think that would cause the problem.

Code:
 @Override
    public void onCreate(Bundle savedInstanceState)
    {
        // android studio generated code, nothing changed
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public void onStart()
    {
        super.onStart();
        openWebPage();  // just a browser intent here
    }
 
I need help. Ever since I installed MinGW, I get errors when I try to compile a .cpp file. There's one solution which is uninstalling MinGW, but I need it in order to run a file in assembly or accessing commands like "g++". I'm using Dev-C++. Can anyone help me?

I got multiple errors of this statement: [Linker error] undefined reference to `__chkstk_ms'
 
I need help. Ever since I installed MinGW, I get errors when I try to compile a .cpp file. There's one solution which is uninstalling MinGW, but I need it in order to run a file in assembly or accessing commands like "g++". I'm using Dev-C++. Can anyone help me?

I got multiple errors of this statement: [Linker error] undefined reference to `__chkstk_ms'
First thing to check, make sure you're looking at the latest Dev-C++. The Bloodshed Software website references this project website, but that says that the project has been superseded by this project website which comes bundled with GCC 4.8.1 instead of the primitive GCC 3.4.2.

Second thing is that Dev-C++ should already come with an installation of MinGW, which might be why you're seeing linker issues. I don't recall if two MinGW installations can co-exist at once. Try removing Dev-C++ and MinGW, and install Dev-C++ with GCC 4.8.1.

That version of Dev-C++ should have all the C++11 features you want. Check the "bin" folder where you installed Dev-C++ and you should see the MinGW bits you need there.


(Since it's probably not clear; MinGW is a Windows port of the compiler GCC with other bits to support using it in a Windows environment. Dev-C++ is a graphical IDE that builds on top of the MinGW compiler infrastructure. GCC 4.8.1 is one of the more recent iterations of the GCC compiler, so MinGW with GCC 4.8.1 is pretty new! And your linker error suggests that Dev-C++ can't find the libraries that it installed with MinGW, which is probably a conflict caused by having a MinGW that Dev-C++ didn't set up itself. Hope that clears up things some.)
 

NotBacon

Member
Anybody familiar with Android? I'm working in Android Studio on a really simple app. It's basically just opening a webpage when I launch the application.

I'm having a problem where the webpage opens before I even click on the app icon. On the emulator, as soon as I unlock the phone, the webpage loads. On my phone, when I unlock it, I see a blank browser tab.

Here's what my onCreate() and onStart() code looks like, assuming the culprit is one of these. I am very, very new to this so I am probably overlooking something that shouldn't be there.

This is just a single class project, so the only other code is the code generated by Android Studio and the openWebPage() method I wrote, but I don't think that would cause the problem.

Code:
 @Override
    public void onCreate(Bundle savedInstanceState)
    {
        // android studio generated code, nothing changed
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public void onStart()
    {
        super.onStart();
        openWebPage();  // just a browser intent here
    }

Sounds like AS is just autostarting your app which is normal when you click the green "play" icon in AS. When the web page launches on your phone, kill the app from recents, then locate your app icon in the drawer and click on that for a normal launch.
 
Sounds like AS is just autostarting your app which is normal when you click the green "play" icon in AS. When the web page launches on your phone, kill the app from recents, then locate your app icon in the drawer and click on that for a normal launch.

Oh, that must be it. Thanks!
 

Kansoku

Member
I've been wanting to make a Android app, but I'm stuck with something.
I want to do something that's like a dictionary, but some entries have a variable number of data (like, variable number of meanings/usage) and I don't know how to deal with it. I think the best would be to use a database, since the data is going to be immutable and also facilitates searching, but I have no idea how to deal with the variable stuff efficiently. On the other hand I was thinking about using JSON, since I can deal with the variable stuff way easier and I can structure it in a good way that helps organizing stuff, but having to parse it every time seems really inefficient, plus doing search would be a little hard. It's my first time dealing with something like this so I'm a little lost.
 
I've been wanting to make a Android app, but I'm stuck with something.
I want to do something that's like a dictionary, but some entries have a variable number of data (like, variable number of meanings/usage) and I don't know how to deal with it. I think the best would be to use a database, since the data is going to be immutable and also facilitates searching, but I have no idea how to deal with the variable stuff efficiently. On the other hand I was thinking about using JSON, since I can deal with the variable stuff way easier and I can structure it in a good way that helps organizing stuff, but having to parse it every time seems really inefficient, plus doing search would be a little hard. It's my first time dealing with something like this so I'm a little lost.

Well, a dictionary is what, a couple megabytes of data? That's probably something you can just keep in memory while the app is running, right? Serialize it to disk in some convenient format, then de-serialize it when the app is starting. Searching through an in-memory data structure with the entries represented as objects of some kind is certainly going to be faster than to go through a database. Is it something where the user can change the data? (add/change entries)
 
I've been wanting to make a Android app, but I'm stuck with something.
I want to do something that's like a dictionary, but some entries have a variable number of data (like, variable number of meanings/usage) and I don't know how to deal with it. I think the best would be to use a database, since the data is going to be immutable and also facilitates searching, but I have no idea how to deal with the variable stuff efficiently. On the other hand I was thinking about using JSON, since I can deal with the variable stuff way easier and I can structure it in a good way that helps organizing stuff, but having to parse it every time seems really inefficient, plus doing search would be a little hard. It's my first time dealing with something like this so I'm a little lost.
SQLite allows you to search text with wildcards. You could put every word in that dictionary into one column of a table and search entries in that table based on the dictionary words.

Just do a SELECT query with the LIKE operator, described in the expressions reference. Stack Overflow has sample usage,

I'd also recommend putting a database index on the column with dictionary words. See section 1.3 of the SQLite query planner docs, it tells you how the database makes decisions, why indexes are good, and how to make one.
 
First thing to check, make sure you're looking at the latest Dev-C++. The Bloodshed Software website references this project website, but that says that the project has been superseded by this project website which comes bundled with GCC 4.8.1 instead of the primitive GCC 3.4.2.

Second thing is that Dev-C++ should already come with an installation of MinGW, which might be why you're seeing linker issues. I don't recall if two MinGW installations can co-exist at once. Try removing Dev-C++ and MinGW, and install Dev-C++ with GCC 4.8.1.

That version of Dev-C++ should have all the C++11 features you want. Check the "bin" folder where you installed Dev-C++ and you should see the MinGW bits you need there.


(Since it's probably not clear; MinGW is a Windows port of the compiler GCC with other bits to support using it in a Windows environment. Dev-C++ is a graphical IDE that builds on top of the MinGW compiler infrastructure. GCC 4.8.1 is one of the more recent iterations of the GCC compiler, so MinGW with GCC 4.8.1 is pretty new! And your linker error suggests that Dev-C++ can't find the libraries that it installed with MinGW, which is probably a conflict caused by having a MinGW that Dev-C++ didn't set up itself. Hope that clears up things some.)
Any particular reason not to just use visual studio? Fully featured visual studio 2013 is free now. Google visual studio 2013 community edition.
 
Any particular reason not to just use visual studio? Fully featured visual studio 2013 is free now. Google visual studio 2013 community edition.

MinGW is the reason programming on Windows gets a bad rep. :( There's very few things in life that I hate with as deep a passion as MinGW.
 
If the question's directed at me, I'm not one to question what tools people use for programming. If it's a good enough text editor and the compiler's reliable, good.

Though I'll amend to that by saying, someone who is serious about developing Win32 apps should use the Microsoft toolchain, Visual Studio and friends. They have access to libraries and low level system details that the folks behind the Clang project are still trying to reverse engineer to figure out.
 
First thing to check, make sure you're looking at the latest Dev-C++. The Bloodshed Software website references this project website, but that says that the project has been superseded by this project website which comes bundled with GCC 4.8.1 instead of the primitive GCC 3.4.2.

Second thing is that Dev-C++ should already come with an installation of MinGW, which might be why you're seeing linker issues. I don't recall if two MinGW installations can co-exist at once. Try removing Dev-C++ and MinGW, and install Dev-C++ with GCC 4.8.1.

That version of Dev-C++ should have all the C++11 features you want. Check the "bin" folder where you installed Dev-C++ and you should see the MinGW bits you need there.


(Since it's probably not clear; MinGW is a Windows port of the compiler GCC with other bits to support using it in a Windows environment. Dev-C++ is a graphical IDE that builds on top of the MinGW compiler infrastructure. GCC 4.8.1 is one of the more recent iterations of the GCC compiler, so MinGW with GCC 4.8.1 is pretty new! And your linker error suggests that Dev-C++ can't find the libraries that it installed with MinGW, which is probably a conflict caused by having a MinGW that Dev-C++ didn't set up itself. Hope that clears up things some.)

Thanks for the link.
 
If the question's directed at me, I'm not one to question what tools people use for programming. If it's a good enough text editor and the compiler's reliable, good.

Though I'll amend to that by saying, someone who is serious about developing Win32 apps should use the Microsoft toolchain, Visual Studio and friends. They have access to libraries and low level system details that the folks behind the Clang project are still trying to reverse engineer to figure out.

Not sure about the question, but fwiw my rant wasn't directed at you, just directed at MinGW. You were just answering the question :)

Btw, clang has actually progressed quite a bit since those blog posts. It can now compile 100% of Google Chrome, and pass its entire suite of unit tests

There is still work to be done of course. C++ exceptions aren't yet supported, and a few other things are only mostly complete. And of course, there's still no viable way to debug these programs since clang can't emit pdb. But that is in progress as well, although the effort is just starting out.

Edit: Being able to debug them is in progress. NOT clang being able to emit pdb
 
I'd forgotten that Dev C++ was active again.

BDBtAQ5.gif
 

Massa

Member
If the question's directed at me, I'm not one to question what tools people use for programming. If it's a good enough text editor and the compiler's reliable, good.

Though I'll amend to that by saying, someone who is serious about developing Win32 apps should use the Microsoft toolchain, Visual Studio and friends. They have access to libraries and low level system details that the folks behind the Clang project are still trying to reverse engineer to figure out.

I think that's the entire point of using Dev-C++ for teaching, that it's not Win32 specific. You'll get similar assignments from students using Windows, Mac or Linux.
 
Stack Overflow is... controversial in some places I've worked.

The trouble is that it will often give you an answer, but the answerer won't tell you how they got there, or what documentation they used, or how they arrived to that conclusion. So you're kind of helpless for additional info, and it leaves you without a well rounded understanding of programming.

In addition, it's not uncommon to find an answer on SO that "works", but ends up being unhelpful and hacky in the long term.. the kind of solution that will bite you in the butt, later.

SO's fine for quick hints from time to time, if you're willing to take a gamble on it. But it's not a good primary source.

When it comes to programming, crowdsourcing doesn't work as well as published documentation or computer books.

This post is couple of days old but I want to chime in...

SnackOverflow is a Q&A site first, and a learning source second. As it has a huge volume, obviously all questions and answers cannot be perfect so some generic media reading comprehension is required. But generally unsourced answers are frowned upon and you always have the tools (flagging and downvoting, plus of course editing) at your hands. Plus generally the quality of the answers gets better every day as the rules and tools get stricter.

But generally the point is not to serve as documentation or as a published resource, but something to push you to correct way. If you are just copypasting stuff from any site, it's already too late.

Giving credit where it's due, SO is a hell of a lot better than the site it replaced.

Experts-Exchange. HOO BOY. That used to be exclusively a pay site, where the questions were free but you'd have to subscribe for answers. And to top it off, the answers were almost always of extremely low quality.

Agreed!
 

Slavik81

Member
MinGW is the reason programming on Windows gets a bad rep. :( There's very few things in life that I hate with as deep a passion as MinGW.
Windows also tends to get bogged down with corporate malware. Looking at file accesses while compiling is depressing. First the .o file is created, then it's opened and read by the anti-virus, then by the other security software, then by the backup utility. Compilation performance was maybe 1/3 of what it could have been.

Building on Linux in a VM was much faster because I was allowed to configure my system in a reasonable manner for development.
 

Kansoku

Member
Well, a dictionary is what, a couple megabytes of data? That's probably something you can just keep in memory while the app is running, right? Serialize it to disk in some convenient format, then de-serialize it when the app is starting. Searching through an in-memory data structure with the entries represented as objects of some kind is certainly going to be faster than to go through a database. Is it something where the user can change the data? (add/change entries)

SQLite allows you to search text with wildcards. You could put every word in that dictionary into one column of a table and search entries in that table based on the dictionary words.

Just do a SELECT query with the LIKE operator, described in the expressions reference. Stack Overflow has sample usage,

I'd also recommend putting a database index on the column with dictionary words. See section 1.3 of the SQLite query planner docs, it tells you how the database makes decisions, why indexes are good, and how to make one.

Thnaks, I will look into that :)
 
Windows also tends to get bogged down with corporate malware. Looking at file accesses while compiling is depressing. First the .o file is created, then it's opened and read by the anti-virus, then by the other security software, then by the backup utility. Compilation performance was maybe 1/3 of what it could have been.

Building on Linux in a VM was much faster because I was allowed to configure my system in a reasonable manner for development.

Eh, almost all virus scanners allow you to choose folders that are excluded from the scan. Choose your source and build output folders. If there's corporate IT policies disallowing that, I'd probably find a new job unless the pay was very high, not because of how slow the compiles would be, but because it's a sign that I'd be dealing with lots of bullshit in general from that company.
 
You mean Chromium right? o_O

Yes but they are not that much different. I suspect all of the official builds can pass too. The big area where the compilers differ is with performance, especially LTO, which clang can't do at all yet. That will just affect performance though, not codegen.
 

Slavik81

Member
Eh, almost all virus scanners allow you to choose folders that are excluded from the scan. Choose your source and build output folders. If there's corporate IT policies disallowing that, I'd probably find a new job unless the pay was very high, not because of how slow the compiles would be, but because it's a sign that I'd be dealing with lots of bullshit in general from that company.
Sysprocmon revealed the antivirus didn't respect its folder limits. A few weeks of back and forth with their support team couldn't resolve the issue. After that, I gave up.

IT would let me turn it off entirely, but I didn't have the heart to tell them it was only one of three problems. Ultimately, it was not a high priority because Linux worked and I was about to quit anyways.

I really just can't stand centralized IT. Nearly every bad experience I've had with Linux has been due to bad configurations by central administrators, too. Windows just tends to get more garbage installed on it by admins.
 
Wow, I am liking all the discussion here.

Btw, clang has actually progressed quite a bit since those blog posts. It can now compile 100% of Google Chrome, and pass its entire suite of unit tests

There is still work to be done of course. C++ exceptions aren't yet supported, and a few other things are only mostly complete. And of course, there's still no viable way to debug these programs since clang can't emit pdb. But that is in progress as well, although the effort is just starting out.

Edit: Being able to debug them is in progress. NOT clang being able to emit pdb
Super neat!

I don't expect Clang to be a true alternative to Microsoft Visual Studio because, well, MS DevDiv shares more resources with the Windows folks than anybody else. But I like being able to have Clang as an alternative compiler for Win32 stuff, and I was impressed with some of the early results people had with Visual Studio + Clang for OpenGL programming.
 
If the question's directed at me, I'm not one to question what tools people use for programming. If it's a good enough text editor and the compiler's reliable, good.

Though I'll amend to that by saying, someone who is serious about developing Win32 apps should use the Microsoft toolchain, Visual Studio and friends. They have access to libraries and low level system details that the folks behind the Clang project are still trying to reverse engineer to figure out.
I was just questioning it because for a newcomer to programming, there a lot of guides out there that recommend some fairly antiquated toolchain setups especially for Windows programming. On Linux when you have things like package managers I feel like it's less of a problem. Our company was hiring interns this week and it was sad how many of then were using Mingw based toolchains. It's not like they were even trying to replicate a familiar environment. They just likely found those same old guides with advice that was relevant a decade ago and went with it.
 

theecakee

Member
Do you all have any advice for getting through a Data Structures and Algorithms class. I take it next semester, and I constantly hear about it being an extremely hard class were some 60% fail.

Just anything to prepare the summer prior.
 
Do you all have any advice for getting through a Data Structures and Algorithms class. I take it next semester, and I constantly hear about it being an extremely hard class were some 60% fail.

Just anything to prepare the summer prior.
Well you can try taking a data structures course over the summer via coursera or something like that.

Here is a book resource: Algorithms, 4th Edition

Look through that book and try implementing the data structures and various algorithms in your language of choice. Really, all it comes down to here is practice. If you're well versed in the data structures before you even take the course, the only thing that could trip you up is the theory but whether or not the theory is difficult is going to be entirely up to your prof. Try asking others at your school what the prof focuses on. Also try to get outlines from previous semesters so that it gives you a rough area of focus for prepping for the course.
 

injurai

Banned
Well you can try taking a data structures course over the summer via coursera or something like that.

Here is a book resource: Algorithms, 4th Edition

Look through that book and try implementing the data structures and various algorithms in your language of choice. Really, all it comes down to here is practice. If you're well versed in the data structures before you even take the course, the only thing that could trip you up is the theory but whether or not the theory is difficult is going to be entirely up to your prof. Try asking others at your school what the prof focuses on. Also try to get outlines from previous semesters so that it gives you a rough area of focus for prepping for the course.

they've got a 4th edition now?

waaaaat
 
Do you all have any advice for getting through a Data Structures and Algorithms class. I take it next semester, and I constantly hear about it being an extremely hard class were some 60% fail.

Just anything to prepare the summer prior.
That's a very good question. I tend to recommend Skiena's Algorithm Design Manual to developers without a CS background, but that's usually for people who have been programming in the industry for some time.

Not that I think pointers and C are a bad fit for students, but given the popularity of "managed" programming languages like Java, JavaScript, Perl, Python and friends, it's just one other thing in there that might be a bit hard to digest.

Sedgewick/Wayne's Algorithms book seems to be a popular choice now, and it has been rewritten in Java for the fourth edition so people with at least AP high school qualifications should be able to read the code without much friction. I have not read this book, so I can't give any personal testimonies as to the quality of writing, source code, etc.

There's also a two part Coursera course based on the Sedgewick book, taught by the authors; part 1, part 2. Since it's part of a MOOC, it's a timed event, and the first part is already underway. You could look into that this weekend, it might have some helpful stuff in there even if you're joining it right in the middle of things.

EDIT: StrangeADT beat me to the punch. :) Still, I think our advice lines up pretty well.
 

Ledbetter

Member
I failed the course of Data Structures (seminar) last semester, and I was looking for some material to learn better, so everything you shared will be helpful. I was taught in C++ because my profesor told us that Java manages data structures in a different way, related to pointers, is that true?

Also, in which semester did you take the Data Structures course? I'm curious.
 
Sysprocmon revealed the antivirus didn't respect its folder limits. A few weeks of back and forth with their support team couldn't resolve the issue. After that, I gave up.

IT would let me turn it off entirely, but I didn't have the heart to tell them it was only one of three problems. Ultimately, it was not a high priority because Linux worked and I was about to quit anyways.

I really just can't stand centralized IT. Nearly every bad experience I've had with Linux has been due to bad configurations by central administrators, too. Windows just tends to get more garbage installed on it by admins.

Definitely agree re: centralized IT. At least at the place i work now, they have all that crap, but give us local admin privileges, and there are ways to get exceptions to some of the more onerous things they do to your machine. So now I've got basically a clean OS I installed from an ISO. Freedom...
 
I have the Sedgewick/Wayne Algorithms book and can tell you 90% of what we did in my Data Structures class last semester was covered in that book and was put in a much easier to understand fashion. You're not getting around theory, but at least that doesn't have to trip you up.
 
I was taught in C++ because my profesor told us that Java manages data structures in a different way, related to pointers, is that true?
The short version is that Java treats every variable and instance variable on an object as a reference in a garbage collected environment.

Which means that you don't have direct access to memory as you would in C/C++, but the Java language and runtime keep you from running into a number of memory related bugs, such as the need to explicitly free every bit of memory you allocate or delete every object you create, at the expense of some slowness.


...there IS an exception to that "no direct access to memory" rule, which is Java's private sun.misc.Unsafe library. But as it says on the tin, it's not something you really want to touch often, or (preferably) at all. Best regarded as black magic, do not use in shipping products unless you have a really good business case for it.

Also, in which semester did you take the Data Structures course? I'm curious.
My memory is fuzzy but I'm almost confident I tried it out sophomore year. Between that and the 200 level class, both were known for having steeper learning curves than the intro course.

For what it's worth, no other 300 level class felt as difficult as Data Structures or what was my 219. Once you get over those mountains, things in my program were much more familiar and generally got easier.
 
I need help, how do I merge two text files or more like two input files into a third file for c++?
You'll have to be more specific and break it down a little more.


The most important question;

What are you trying to do, in the big picture? What is this for?


And then a torrent of smaller questions, based on exactly what you've described;

What do you mean by "merge"? How are you planning on doing a "merge"?

When you say "two input files into a third file", do you mean that you want a third file that is exactly the length of the first two files combined, and the contents of that "third file" will be the contents of the first file, immediately followed by the contents of the second file?

Where is this third file going to be stored? Is this file going to be saved to disk, or do you want it to be done entirely in memory?


C++ has file streams to work with files of every kind, you should look into that.

It would help to pick up a book on C++ so that you can have all this information laid out for you, the C++ Primer is a popular choice, and Scott Meyers recently released another book in the "Effective C++" series, Effective Modern C++. I would recommend picking up those this weekend.
 
You'll have to be more specific and break it down a little more.


The most important question;

What are you trying to do, in the big picture? What is this for?


And then a torrent of smaller questions, based on exactly what you've described;

What do you mean by "merge"? How are you planning on doing a "merge"?

When you say "two input files into a third file", do you mean that you want a third file that is exactly the length of the first two files combined, and the contents of that "third file" will be the contents of the first file, immediately followed by the contents of the second file?

Where is this third file going to be stored? Is this file going to be saved to disk, or do you want it to be done entirely in memory?


C++ has file streams to work with files of every kind, you should look into that.

It would help to pick up a book on C++ so that you can have all this information laid out for you, the C++ Primer is a popular choice, and Scott Meyers recently released another book in the "Effective C++" series, Effective Modern C++. I would recommend picking up those this weekend.

My objective is to allow users to input two input file names that already exists, and both of these files contains sorted list of integers per-line in increasing order. I'm not sure whether the third file have to be saved on disk or in memory. The question didn't specify that. After the two files have merged into a third file, I have to ask the user for the name of the merged file. Another question, am I allowed to put a string variable into the .open() function? The compiler complains about that, and when I actually put a string literal into that function, the compiler doesn't complain. I want to use string variables to ask users to input file names.
 
Another question, am I allowed to put a string variable into the .open() function? The compiler complains about that, and when I actually put a string literal into that function, the compiler doesn't complain.
Yes, the C string literal is an array of "char" variables. It is NOT a C++ string object.

You can get a C string out of a C++ string. It should be in the documentation for the standard C++ library, whichever resource you're using. If you DON'T have documentation like that, that is why you should pick up a resource like the C++ Primer immediately. :)

Online resources can help, too. cplusplus.com has a listing for std::string, check under "string operations". You'll see a link with examples that should help you out.

You've got some holes in your knowledge of C++ that you need to patch up, particularly with its relation to C and how the two languages differ (like C string literals and the C++ std::string object). This is why I think you need to pick up a primer or a similar intro resource. For now, you can get by with cprogramming.com and cplusplus.com.

I think you're headed in the right direction, otherwise. The C++ file stream should suit you just fine in the meantime, but let us know if you have more specific questions.


EDIT: Last thing. If they didn't specify what to do with the third file, I assume they do want it saved to disk.

There is a way to treat a block of memory like a file on disk, but that seems pretty far outside the scope of what you're being asked to do.
 

mooooose

Member
Hey, I'm new to Ruby and I need some help. I'm looking to use Nokogiri to scrape this webpage:

http://www.acronymslist.com/

I've been able to scrape the acronyms, because they are tagged with a class called special, so I just did:

Code:
ac = doc.css("a[class=special]")

But for the meanings, its harder. They're just cells in a table. I don't know how to get them alone. They're just in <td> and <tr> tags.

I tried this:

Code:
	ex = doc.css("tr").css("td").css("tr").css("td").css("tr").css("td")

But it didn't work, it was just a mess of text.

Any ideas?
 

Ace 8095

Member
Any R programmers? I need to learn some basic R programming for work and was wondering what the best resources are. I'm currently going through the Coursera R programming course but wondered if there's a better option. I know nearly nothing about programming other than some basic SQL so I need tools that assume no prior programming knowledge.
 
Finished my intro to C++ book by John Smiley, great book and really enjoyed working and reading through it.

One question - how important is documentation & note making? It is impossible to memorize all the different commands and what they do, I should create my own documentation that will help me out right?
 
Any R programmers? I need to learn some basic R programming for work and was wondering what the best resources are. I'm currently going through the Coursera R programming course but wondered if there's a better option. I know nearly nothing about programming other than some basic SQL so I need tools that assume no prior programming knowledge.
I was impressed with these three:

R For Dummies

- Generally Wiley's Dummies books are AWFUL for teaching programming, but this one's actually very approachable and gives the best treatment of the cross-platform R IDE, RStudio, that I've seen. Very nicely put together. Also handles some seemingly obvious questions that'll come up in the workplace like "how do I use R with an Excel spreadsheet."

The Art of R Programming

- More advanced than the previous book, and it assumes some programming knowledge, but it covers more interesting material like what you can do with certain R packages and gives a thorough treatment of what the language can do. Seems like a good one to help build your knowledge on.

The R Cookbook

- O'Reilly has a series of "cookbooks" that are basically simple solutions in code for very specific problems. You could go through these books back to front and learn a fair amount, or keep them on your shelf for when the time comes that you need something non-trivial. Recently, they also put out an R Graphics Cookbook which you might want to take a look at later if this one suits your fancy.


The official R documentation has struck me as extremely hard for beginners to hit the ground running with, and before O'Reilly, No Starch and even Wiley threw their hats into the game, the best resources for learning R were expensive books from Springer that weren't much good if you wanted to use a not-Windows operating system. Hopefully these help you out.
 
One question - how important is documentation & note making? It is impossible to memorize all the different commands and what they do, I should create my own documentation that will help me out right?
C++ is a few orders of magnitude more complex than most programming languages, I could see building some cheat sheets and taking some notes for a notebook helping out.

When most people say "documentation" in programming, usually the first thing that comes to mind is "comments" and (for some contract work) "high level overviews of functionality and source code".

Generally speaking, if something looks like you won't understand it a year out, you should comment it. If it looks like something that you'll have to explain, comment it.

The ideal is to write code that's so readable, with descriptive variable and function/method names, that someone won't need comments or extra documentation to understand it. I've yet to see a moderately sized code base fully achieve this goal, but for the sake of making things you WANT to come back to and fix, adjust and tweak, it's a good thing to strive for.
 
Hey, I'm new to Ruby and I need some help. I'm looking to use Nokogiri to scrape this webpage:

http://www.acronymslist.com/

I've been able to scrape the acronyms, because they are tagged with a class called special, so I just did:

Code:
ac = doc.css("a[class=special]")

But for the meanings, its harder. They're just cells in a table. I don't know how to get them alone. They're just in <td> and <tr> tags.

I tried this:

Code:
	ex = doc.css("tr").css("td").css("tr").css("td").css("tr").css("td")

But it didn't work, it was just a mess of text.

Any ideas?
This site seems hairy because none of the elements have IDs or classes. That said, there is always a way, and in this case it's with XPath. The way I've done this in the past is to use Firebug (Firefox addon) with FirePath (a plugin for XPath). It lets you click on any element on the site and gives you an XPath expression to get there. Not always optimal but it's a start. You can also enter your own XPath expressions and see on the page which elements they select. It's really useful.

edit: To clarify, you could also be using CSS selectors but I have no experience with those.
 

hateradio

The Most Dangerous Yes Man
edit: To clarify, you could also be using CSS selectors but I have no experience with those.
If Nokogiri can get the node's parent, it could be possible to traverse up the tree to get the TR where the TD with the meaning resides.

Code:
ac = doc.css("a[class=special]")

ac.each { |anchor|
  tr = anchor.parent.parent // ??? until you get the tr
  meaning = tr.css("td:nth-child(4)").text.trim // 4th td in the tr
}

However, I just noticed that this seems to match some of the meanings.

Code:
td + td[width][style="vertical-align: middle"]

Meaning that any TD next to a TD with a width attribute and a style that has "vertical-align: middle".
 
Finished my intro to C++ book by John Smiley, great book and really enjoyed working and reading through it.

One question - how important is documentation & note making? It is impossible to memorize all the different commands and what they do, I should create my own documentation that will help me out right?

I don't think it's necessary to keep notes of this sort. Learn to use man pages or -- if you're on windows -- MSDN. Usually you can find what you're looking for if you even remember a simple related function. For example, suppose you're trying to remember which function searches a string for a substring. But you remember that strlen() computes the length. Search for that and pick your favorite site from the search results (good ones are MSDN and cppreference.com, and cplusplus.com) and you will find a list of related functions, one of which is strstr(), the function you're looking for.

So you really just have to remember the basics, and learn to find the rest
 

endre

Member
I want to get into programming again and I started with this wpf tutorial, since I want to familiarize myself with wpf. I have downloaded the provided source, however none of the changes I make in the code apply. Could this be a conversion issue since I am using VS2013?
 
Top Bottom