I have a test in C on wednesday, and I don't think I'll make it.
If I have to repeat, I'm gonna bug you guys with stupid questions all through the semester.
Can't wait.
But seriously, study.
I have a test in C on wednesday, and I don't think I'll make it.
If I have to repeat, I'm gonna bug you guys with stupid questions all through the semester.
I don't think I'll ever get my competitiveness completely out of sight, but maybe I could use a little more zenhabits in my life.
Thanks Spoo, really appreciate your 2 cents.
Quick question to you guys: at what age did you start coding?
I took a programming class when I was only 15 or 16 and it didn't click with me.
Introduction to Algorithms - This was the required book in my Algorithms class. The closest thing to a bible we have in Computer Science. I'm not kidding. This book covers pretty much everything. It dives deep into the analysis of algorithms and shows detailed proofs. Undergrads hate it, but grad students and professors love it.
yeah, this is probably what you want
Agreed. The CLRS is pretty much the standard.
There are people who don't think that?Anyone else think Java is one of the worst languages to be widely adopted?
There are people who don't think that?
Anyone else think Java is one of the worst languages to be widely adopted?
Anyone else think Java is one of the worst languages to be widely adopted?
What do you hate about it?
So much stuff deprecated and forced try catch blocks.
Or i did something wrong.
I just sort of dislike object-oriented paradigms; the point is to make things simpler and easier for the programmer, so why is it so complicated? (overloading, autoboxing, wrapper classes, recursion, etc.)
So much stuff deprecated and forced try catch blocks.
Or i did something wrong.
new ArrayAdapter<String>(
actionBar.getThemedContext(),
android.R.layout.simple_list_item_1,
android.R.id.text1,
names),
this);
I just sort of dislike object-oriented paradigms; the point is to make things simpler and easier for the programmer, so why is it so complicated? (overloading, autoboxing, wrapper classes, recursion, etc.)
Does anyone have ADT installed? I'm relearning Android.
Something REALLY bugs me. If you create a project using the wizard, set to 4.1.1, use dropdown action bar option. There's this bit of code from the template:
Code:new ArrayAdapter<String>( actionBar.getThemedContext(), android.R.layout.simple_list_item_1, android.R.id.text1, names), this);
I can't find any "simple_list_item_1" under the layout folder, nor even as part of the code. Same goes for "text1". Where are they? What are they?
int *function(char string[]){
/*do something with the string*/
return string;
}
Yep. Fall under the undergrad title so I "hate" it, but it's a pretty good book.
Just wish they indexed things starting at 0 instead of one, but I'm just picky about stupid stuff like that.
We use it in my Data Structures class (intro to algorithms)
I need some urgent beginner help for a test:
If I want a function to return a pointer in C, how do I do that? Do I need a * in front of the function's name?
For instance:
Code:int *function(char string[]){ /*do something with the string*/ return string; }
Is that the right way to do it?
Pointers are fucking with my head. I never know where to set the '*' and where I dont.
Like if I were to call that function above, would i need function(string); or function(*string); (Also, string[] would be equivalent to *string, right?).
Thanks in advance.
#include "stdlib.h"
#include "stdio.h"
char* copy_string(char* string, int len)
{
int i = 0;
char* new_string = malloc(sizeof(char) * len);
for (i = 0; i < len; ++i)
{
new_string[i] = string[i];
}
return new_string;
}
int main()
{
char* string = copy_string("abc\n", 4);
printf("%s\n", string);
}
#include "stdlib.h"
#include "stdio.h"
int return_number_value()
{
return 2;
}
int* return_number_pointer()
{
int* value = malloc(sizeof(int));
*value = 3;
return value;
}
int main()
{
printf("%i\n", return_number_value()); //value returned
printf("%i\n", return_number_pointer()); //pointer returned
printf("%i\n", *return_number_pointer()); //pointer dereferenced
}
I just sort of dislike object-oriented paradigms; the point is to make things simpler and easier for the programmer, so why is it so complicated? (overloading, autoboxing, wrapper classes, recursion, etc.)
Maybe I'm just dumb but I feel much more comfortable in a language like C++.
(edit: Yes, I realize C++ is an object-oriented language, but the need to adopt an object-oriented paradigm is much more "optional", since object-oriented functionality was kind of just thrown on top of regular C; you can use it a lot more like regular C with some extra functionality added to C++ and it's fine.)
I'm not saying that Java is the best language ever or anything, but the reasons you state (with the exception of autoboxing, I'll give you that) don't make any lick of sense. The last one especially is pretty hilarious.
It's a build in XML layout document,
http://stackoverflow.com/questions/3663745/what-is-android-r-layout-simple-list-item-1
What free online SVN repos do you guys recommend, preferably private?
Oh wow thanks man! It's baffling how it looks way too much like a generic var name.
Quick question to you guys: at what age did you start coding?
I took a programming class when I was only 15 or 16 and it didn't click with me.
Now I'm nearly 28 and I took another crack at it last year and it's coming along great. I feel like another few months of hard work and I'll be able to start coding professionally. The only thing is that I feel I've wasted so many years NOT learning this stuff, when it turns out that all I needed was the right teacher to make me love learning it all. I'm excited at the prospects of doing this professionally, but I feel like a (relative) dinosaur to my peers. Anyone else start coding this late in life and find success with it?
I just sort of dislike object-oriented paradigms; the point is to make things simpler and easier for the programmer, so why is it so complicated? (overloading, autoboxing, wrapper classes, recursion, etc.)
Maybe I'm just dumb but I feel much more comfortable in a language like C++.
(edit: Yes, I realize C++ is an object-oriented language, but the need to adopt an object-oriented paradigm is much more "optional", since object-oriented functionality was kind of just thrown on top of regular C; you can use it a lot more like regular C with some extra functionality added to C++ and it's fine.)
Bitbucket offers unlimited private repos
Quick question to you guys: at what age did you start coding?
struct afce{
char quarterback[20];
char coach[20];
int wins;
struct AFCE *next;
};
struct afce patriots;
patriots.quarterback="Tom Brady";
patriots.coach="Bill Belichick";
patriots.wins=12;
patriots.next=&dolphins;
There's still no consensus on 0 vs 1 as default base for arrays, so I would argue that it is a completely legitimate decision to make. 0 makes sense when you think of the index as an offset to an address. 1 makes sense when you think of it as an actual index.
For some reason, I was thinking about this the other day...
I honestly can't see any benefit to having 1 as the base, except that it is slightly easier for extreme newcomers to understand. 0 just works for everything, whether it's graphics (start drawing at i * spacing + offset, if i starts at 1, then that's just annoying) or just number systems in general (a 128 element array would only take one signed byte from 0 to 127).
I didn't know using 1 as a base was even a thing until my Java professor said that some prefer to start at 1 and to init the array as size+1, and all I could think of was why someone would do that. lol
6. Though obviously I didn't do it professionally until quite a bit later - I must have been at least 12 before I made money with my code.![]()
Must resist avatar quote.
Jebus man! 6?!!! Did you even know how to read by that time?
Alright, another simple question (in C):
Why is this returning syntax errors? It complains about the team name in the initialization (Syntax error before '.' token). I'm pretty sure I've done it the same way before without problems...
Code:struct afce{ char quarterback[20]; char coach[20]; int wins; struct AFCE *next; }; struct afce patriots; patriots.quarterback="Tom Brady"; patriots.coach="Bill Belichick"; patriots.wins=12; patriots.next=&dolphins;
That's right. He could also pass in the strings through a static initializer for the struct.I haven't worked with C in a while, but I don't think you can do that. Both of you char arrays quarterback and coach can't be assigned the way you are doing. You might need to use string copy.
I haven't worked with C in a while, but I don't think you can do that. Both of you char arrays quarterback and coach can't be assigned the way you are doing. You might need to use string copy.
struct afce{
char quarterback[20];
char coach[20];
int wins;
struct AFCE *next;
}patriots={"Tom Brady", "Bill Belichick", 12, &dolphins};
Yeah, I just found that somewhere, and it makes absolutely no sense to me. Because if I do it like this
Code:struct afce{ char quarterback[20]; char coach[20]; int wins; struct AFCE *next; }patriots={"Tom Brady", "Bill Belichick", 12, &dolphins};
it works, and I don't get how the char array would behave differently if it's done the other way, especially since it works with other types.
Oh well, lesson learned, I guess. Thanks!
When I was 8 I made a really terrible rpg random battle game in GW-BASIC on my Tandy 1000. Basically you just kept encountering random enemies until you died. You could attack, magic attack, or heal. There was no way to gain back mp or hp.Must resist avatar quote.
Jebus man! 6?!!! Did you even know how to read by that time?
Pointers are fucking with my head. I never know where to set the '*' and where I dont.
Like if I were to call that function above, would i need function(string); or function(*string); (Also, string[] would be equivalent to *string, right?).
Thanks in advance.
6. Though obviously I didn't do it professionally until quite a bit later - I must have been at least 12 before I made money with my code.![]()
I'm starting to get an idea of how to not go crazy when planning code. Here are my findings.
Whenever you start to get an inkling of starting to get an inkling of feeling overwhelmed:
DO NOT take a 10 minute break
DO spend 10 minutes in front of a blank sheet of paper
Blank paper, man. It's magic.
So you think it's better to write code that's guaranteed to bomb out completely in an error condition without letting the developer know that's a bad idea? Rather than letting your IDE throw in a try/catch block for you and handling the error condition sensibly?
I think it's way easier to do a little planning in your head and start coding, then refactor that formless pulp of code into a beautiful program.
TDD is way better for this than a piece of paper since it actually forces you to think how you are going to use that code and then follow the cycle of make it fail, make it work, make it better. I'm not a full believer of TDD but it works very well in those situations.
6. Though obviously I didn't do it professionally until quite a bit later - I must have been at least 12 before I made money with my code.![]()
When I was 8 I made a really terrible rpg random battle game in GW-BASIC on my Tandy 1000. Basically you just kept encountering random enemies until you died. You could attack, magic attack, or heal. There was no way to gain back mp or hp.
because mathematically it's easier, and it makes things really nice when representing trees as arrays or solving connected graph problems.
That's the problem starting with high level languages. Once you dip assembly, pointers become a not so complicated tool that can make things rather simple. But that's just another rant about CS Educations nowadays...
Oh I know. Just jarring for a bit to go from 0 -> n-1 to 1 -> n after using the former for so long.
Yeah. The class I took last semester that dealt with assembly made pointers and arrays (and subsequently c strings) that much easier to understand. It was also supposed to be taken after your entry level classes too.
edit: (C++) I have a list of elements which happen to be spaces in 2d space. I need to store and access them to manipulate them (delete, move, reshape/size etc.) Throwing ideas here, would it be best to declare a vector of strings and use it that way? Ideally each string element would have the coordinates of the object. Unless I can do a vector of float arrays?
class Point
{
private int x;
private int y;
...
}
I could but I need a dynamic container to hold the values. I figure <vector> would be easier (and it's either that or lists as a requirement so...)
Yeah, but what I was saying is that you could have a vector of points.
edit: unless I completely misunderstood your question.
#include <iostream>
#include <string>
using namespace std;
void reverse(string, int, string&);
int main()
{
string input1, input2, returned;
int length, palindromechecker;
getline(cin, input1);
length = input1.length();
reverse(input1, length, returned);
cout << returned << endl;
palindromechecker = input1.compare(returned);
cout << palindromechecker << endl;
return 0;
}
void reverse(string input1, int length, string& returned)
{
for(int i = length; i > -1; i--)
{
returned += input1[i];
}
}
Ah misread what you said.
And yeah I already have them in a class, but I figure strings would be better because it can either be a point, line segment, triangle, rectangle, or circle, hence why I was thinking an array of some sort would be best, ala strings.
Can anyone explain to me what the fuck is going on...
![]()
xcode is barfing all over the fucking place with this class definition. And I for the life of me cannot figure out why.
#ifndef DRAWOBJECT_H
#define DRAWOBJECT_H
class DrawObject {
...
};
#endif