|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On April 07 2014 17:41 darkness wrote:Show nested quote +On April 07 2014 10:19 TimKim0713 wrote: What is a "client class"?
I see them on comp sci multiple choice, and got a little confused... how is it different from a normal class?
Maybe this question is about the client-server architecture. You have a server class (e.g. Java RMI, IRCd, Skype, etc), and a client class to connect to the server (e.g. Java RMI, XChat/mIRC, Skype client, etc). This is a bit simplified because their clients may not use only one class, but in the case of RMI it's posible to have only one client class. Actually, it may not be required to have only one client class. I suppose it's acceptable to call many classes "client" per application. Example (Java RMI): http://web.cs.wpi.edu/~rek/DCS/D04/JavaRMI.html No, in this situation (I assume this is an intro CS course here) the client class is simply the class with the main method.
|
On April 09 2014 09:16 misirlou wrote:Not exactly programming but think it's the best place to post this: I was testing teamliquid.net against the Heartbleed bug when I noticed that TL doesn't use HTTPS at all. Could you please make atleast www.teamliquid.net/mytlnet/login.php forceably run over https so I don't have my password (atleast it's a generic one that i use for minor stuff) flying around in plain text? Onto the Heartbleed discussion: This is a pretty major exploit, that allows you to read some (maybe all of it?) ram from the host running openSSL, 64kB at a time. This exploit can very easily retrieve a host's private key to be used in impersonation attacks, read a lot of confidential content and even hijack web server user sessions. The bug was made public yesterday yet it took some companies like yahoo almost 24hours to fix it (was simply updating/downgrading openSSL on their servers or manually disabling the module causing the bug) and others still haven't reacted. Seeing so much info out on what can be done with this exploit just studied in 24hours makes me wonder how much of it was already thought out before public awareness and how much entities (hello NSA) have exploited this for the last 2 years (bug was deployed in 2012) Wouldn't this rather go in website feedback, or directly to R1CH?
|
On April 08 2014 21:04 3FFA wrote:I have a problem where my words[] array of strings fails to be accessed by another class that needs to use it. Switching which class has extends(to experiment if that was the problem) failed. Anyone have any ideas for how to fix this? Some code is below: + Show Spoiler +package sorter;
public class Sorter extends Word {
public static void main(String[] args) { //declare variables String words[] = {"hi", "pie", "schoolmaster", "theclassroom", "meteor", "remote", "racecar", "racecar", "nap", "pan", "God", "dog"};}} package sorter;
public class Word{ private String word;
public void setWord(String w) { word = w; } public String getWord(int i) { return words[i]; //asks for me to create the local variable words. }
I think:
If Sorter is extending Word, then Word has no idea that words[] exists.
If Word is extending Sorter, String words[] exists in the main method, and again Word has no idea that words[] exists (Word only sees the variables declared in Sorter class itself, which in the code snippet there are none).
Where is getWord() being called?
I can't say it makes too much sense to me for either to be extending the other one... but eh. :|
On April 08 2014 21:25 DeltaX wrote: Your variable names and types seem off. You declare a string "word" and try to reference "words[]" and "words". You want it to be a String[] instead of a string, decide if you want your variable name to be singular or plural and don't use [] on variable names unless you want to reference a specific element in the array.
I think Java (not sure Java is actually being used here, but looks like it to my untrained eye ; has a weird/whatever thing where you can declare arrays as either Type[] variableName or Type variableName[]. At least it brings back memories of seeing both main(String[] args) or main(String args[]). That said, I'm far more used to seeing Type[] rather than variableName[].
|
On April 10 2014 02:29 spinesheath wrote:Show nested quote +On April 09 2014 09:16 misirlou wrote:Not exactly programming but think it's the best place to post this: I was testing teamliquid.net against the Heartbleed bug when I noticed that TL doesn't use HTTPS at all. Could you please make atleast www.teamliquid.net/mytlnet/login.php forceably run over https so I don't have my password (atleast it's a generic one that i use for minor stuff) flying around in plain text? Onto the Heartbleed discussion: This is a pretty major exploit, that allows you to read some (maybe all of it?) ram from the host running openSSL, 64kB at a time. This exploit can very easily retrieve a host's private key to be used in impersonation attacks, read a lot of confidential content and even hijack web server user sessions. The bug was made public yesterday yet it took some companies like yahoo almost 24hours to fix it (was simply updating/downgrading openSSL on their servers or manually disabling the module causing the bug) and others still haven't reacted. Seeing so much info out on what can be done with this exploit just studied in 24hours makes me wonder how much of it was already thought out before public awareness and how much entities (hello NSA) have exploited this for the last 2 years (bug was deployed in 2012) Wouldn't this rather go in website feedback, or directly to R1CH?
Afaik R1CH has mentioned before they consciously don't run over HTTPS - the reasoning being that your TL pw shouldn't be so secure anyway. I disagree with the reasoning but not my place to complain.
Just thought I'd share a cool/useful library I found called livestreamer - http://livestreamer.tanuki.se/en/latest/ - really useful for watching streams on Twitch easily.
I'm not so good at coding python but put together a few simple shell scripts to record a twitch stream from a given time to a given time and save the .flv file using the libraries CLI. I've been using it to watch GSL and ATC lately since the time isn't so good for me.
|
On April 08 2014 21:04 3FFA wrote:I have a problem where my words[] array of strings fails to be accessed by another class that needs to use it. Switching which class has extends(to experiment if that was the problem) failed. Anyone have any ideas for how to fix this? Some code is below: + Show Spoiler +package sorter;
public class Sorter extends Word {
public static void main(String[] args) { //declare variables String words[] = {"hi", "pie", "schoolmaster", "theclassroom", "meteor", "remote", "racecar", "racecar", "nap", "pan", "God", "dog"};}} package sorter;
public class Word{ private String word;
public void setWord(String w) { word = w; } public String getWord(int i) { return words[i]; //asks for me to create the local variable words. }
public class main {
/** * @param args */ public static void main(String[] args) { Wordlist wordlist = new Wordlist(); wordlist.setWord("cool"); wordlist.setWord("awesome"); System.out.println(wordlist.getWords().toString());
}
} import java.util.ArrayList;
public class Wordlist {
/** * @param args */ private ArrayList<String> words; public Wordlist() { words = new ArrayList<>(); }
public void setWord(String word) { words.add(word); } public ArrayList<String> getWords() { return words; } } You don't want to use normal arrays too much they are good to learn. But not really used that much anymore since you can't really add data to it. If you say an array is 10 long, it will always be 10 long. If you want to make it larger you need to make a new array and copy the other array into it. Better to start with Arraylist, and don't use extend for this case!
|
Using an ArrayList instead doesn't do anything in terms of a solution to his problem.
Why did you make a class called Word in the first place? Either you're going to have an array of Strings which means the Word class is pointless or you need to have an array of Word objects.
A subclass doesn't inherit fields and since it is private you can't access it. Use a getter.
|
On April 09 2014 06:55 darkness wrote: Does anyone have experience with JTable? I'm trying to display a unique ComboBox for each row, but what is displayed is ComboBox.toString() instead. I've found some examples but 1) they use the same ComboBox for every row or 2) code doesn't work for me. I understand I need to set Cell editor and renderer, but I'm not doing it right I guess.
Overall, the ComboBox is supposed to be a drop-down list that is read-only. I only want the user to view items per list with no modification.
Edit: ComboBox isn't required exactly. I just want to display an array of items.
I can't think of a good way short of extending JTable and messing around with that. But I'm no JTable expert. =/
If you're looking to display an array (of an array?) of items, JTrees were pretty easy to work with. Another way could be to just make multiple ComboBoxen in a loop and have them displayed on top of each other.
|
GRAND OLD AMERICA16375 Posts
C question (not my first language, but I'm liking this language a lot so why not)
Whats the best way to convert int to chars and to concatenate chars? In my case, I would like to concatenate members of a structure into a single char array so that I can easily just spit it back out into my front end (which is just a console)?
|
On April 10 2014 05:50 amazingxkcd wrote: C question (not my first language, but I'm liking this language a lot so why not)
Whats the best way to convert int to chars and to concatenate chars? In my case, I would like to concatenate members of a structure into a single char array so that I can easily just spit it back out into my front end (which is just a console)?
Are you trying to format a string (string=char array)? If so, then sprintf is your friend. You could also use itoa.
If you're trying to extract the data of the int into a byte array, then you can either memcpy it or use a char* pointer to the start of data. Note that (most)type-punning isn't strictly legal C.
//string formatting using sprintf char buffer[100]; sprintf(buffer, "my numbers are %d, %d, and %d, and my string is %s",my_struct.nums[0], my_struct.num[1], my_struct.nums[2], my_struct.str);
|
On April 10 2014 05:00 Blitzkrieg0 wrote: Using an ArrayList instead doesn't do anything in terms of a solution to his problem.
Why did you make a class called Word in the first place? Either you're going to have an array of Strings which means the Word class is pointless or you need to have an array of Word objects.
A subclass doesn't inherit fields and since it is private you can't access it. Use a getter.
Learning object oriented programming, you still want to use arraylists. The only thing that is advantageous about arrays is that it is faster, and that every programming language have it implemented. Still it is outdated and lacks functionality. Well that Word class is just for learning OOP i guess?
|
On April 10 2014 05:00 Blitzkrieg0 wrote: Using an ArrayList instead doesn't do anything in terms of a solution to his problem.
Why did you make a class called Word in the first place? Either you're going to have an array of Strings which means the Word class is pointless or you need to have an array of Word objects.
A subclass doesn't inherit fields and since it is private you can't access it. Use a getter.
Yeah well, I favor array lists as well but my teacher wanted us to use array lists, she also wanted us to set up the classes in a weird way, rather than the single class program I made in my first version(working FYI >.>). Anyways, turns out a classmate still beats TL when it comes to answering certain programming questions. Apparently I just wasn't understanding what it was that my teacher wanted.(Leading to everyone here being confused about the word class. In fact, even though I got this fixed, I still don't understand why she had us format it so weirdly)
|
|
|
On April 10 2014 07:25 3FFA wrote:Show nested quote +On April 10 2014 05:00 Blitzkrieg0 wrote: Using an ArrayList instead doesn't do anything in terms of a solution to his problem.
Why did you make a class called Word in the first place? Either you're going to have an array of Strings which means the Word class is pointless or you need to have an array of Word objects.
A subclass doesn't inherit fields and since it is private you can't access it. Use a getter. Yeah well, I favor array lists as well but my teacher wanted us to use array lists, she also wanted us to set up the classes in a weird way, rather than the single class program I made in my first version(working FYI >.>). Anyways, turns out a classmate still beats TL when it comes to answering certain programming questions. Apparently I just wasn't understanding what it was that my teacher wanted.(Leading to everyone here being confused about the word class. In fact, even though I got this fixed, I still don't understand why she had us format it so weirdly)
She was probably trying to explain static vs non-static. I'm guessing since you're Sorter class extends the Word class, it is going to have to access words statically.
Note that the addition of protected static String[] words; makes Word.words a single array available to all classes within the package. words is being used by getWord(int). So it doesn't make sense to declare it in the narrow scope of the main function. Instead there should be a single words array for the whole class. That's what static is.
package sorter;
public class Word{ private String word; protected static String[] words;
public void setWord(String w) { word = w; } public String getWord(int i) { return words[i]; //asks for me to create the local variable words. } }
package sorter;
public class Sorter extends Word { public static void main(String[] args) { //declare variables words = new String[]{ "hi", "pie", "schoolmaster", "theclassroom", "meteor", "remote", "racecar", "racecar", "nap", "pan", "God", "dog" }; }
}
All that aside, the way these classes are set up makes no practical sense...
|
On April 10 2014 08:25 Nesserev wrote:
EDIT: I think that, if the front end wouldn't be the console, that you would have to save the string in a buffer (like you said) to use it for your front end (like a GUI, but I don't think it's a good thing to design a GUI in C).
In the case that you do need to store the concatenated string instead of simply printing to command line, also make sure that you are using a safer method. Either do VERY careful bounds checking before your call to sprintf, or use snprintf or something similar.
|
GRAND OLD AMERICA16375 Posts
On April 10 2014 08:25 Nesserev wrote:Show nested quote +On April 10 2014 06:10 RoyGBiv_13 wrote:On April 10 2014 05:50 amazingxkcd wrote: C question (not my first language, but I'm liking this language a lot so why not)
Whats the best way to convert int to chars and to concatenate chars? In my case, I would like to concatenate members of a structure into a single char array so that I can easily just spit it back out into my front end (which is just a console)? Are you trying to format a string (string=char array)? If so, then sprintf is your friend. You could also use itoa. Even though your way works, it's way too 'excessive', and can be risky or limiting; it's not the best way in my opinion: Use a function that calls printf (not sprintf), with the struct as it's argument, and prints the data directly to the console: - don't need to store the full string every time (which is way less redundant) - no need for a buffer, no risk of buffer overflows (you don't have to worry about whether or not your C string in your structure can be too long for your buffer, and vice versa) EDIT: I think that, if the front end wouldn't be the console, that you would have to save the string in a buffer (like you said) to use it for your front end (like a GUI, but I don't think it's a good thing to design a GUI in C). Or am I missing something big? All I did was read Kernighan and Ritchie's 'The Ansi C Programming Language' (2nd Ed.). EDIT2: Show nested quote +On April 10 2014 09:32 phar wrote:On April 10 2014 08:25 Nesserev wrote: EDIT: I think that, if the front end wouldn't be the console, that you would have to save the string in a buffer (like you said) to use it for your front end (like a GUI, but I don't think it's a good thing to design a GUI in C).
In the case that you do need to store the concatenated string instead of simply printing to command line, also make sure that you are using a safer method. Either do VERY careful bounds checking before your call to sprintf, or use snprintf or something similar. Of course 
so for printf
say i had like
struct example { int a; int b; } example ex = {1, 2}; printf("%d%d", ex);
would get me 12 right?
|
so for printf say i had like
struct example { int a; int b; } example ex = {1, 2}; printf("%d%d", ex);
would get me 12 right?
I would write
printf("%d%d", ex.a, ex.b);
to print 12.
|
Sorry for asking this stupid question but I'm trying to get into programming in C again. I took a class in C while in school and the compiler we used was called "Putty." Now I've graduated and I don't have access to that anymore and was wondering what is a good compiler people use for C? Thanks.
This thread is so big so I tried googling this thread to try to help me narrow down a page but couldn't find it.
|
PuTTY is not a compiler, it's an ssh client (and a bunch of other stuff, but definitely not a c compiler).
gcc is a pretty standard c compiler
if you want to live in windows only world you can try visual studio's compiler (free version should have a sufficient compiler) http://www.visualstudio.com/en-US/products/visual-studio-express-vs
(you can also use gcc on windows, either via cygwin or probably some windows port of gcc)
|
On April 10 2014 14:03 phar wrote:PuTTY is not a compiler, it's an ssh client (and a bunch of other stuff, but definitely not a c compiler). gcc is a pretty standard c compiler if you want to live in windows only world you can try visual studio's compiler (free version should have a sufficient compiler) http://www.visualstudio.com/en-US/products/visual-studio-express-vs(you can also use gcc on windows, either via cygwin or probably some windows port of gcc)
MinGW is way simpler to set up than cygwin and it's a pretty damn good gccfor windows =D and obviously just gcc itself if you're on linux, I guess clang or something if you on mac? I'm not really a mac guy lol
|
On April 09 2014 09:16 misirlou wrote:Not exactly programming but think it's the best place to post this: + Show Spoiler +I was testing teamliquid.net against the Heartbleed bug when I noticed that TL doesn't use HTTPS at all. Could you please make atleast www.teamliquid.net/mytlnet/login.php forceably run over https so I don't have my password (atleast it's a generic one that i use for minor stuff) flying around in plain text? Onto the Heartbleed discussion: This is a pretty major exploit, that allows you to read some (maybe all of it?) ram from the host running openSSL, 64kB at a time. This exploit can very easily retrieve a host's private key to be used in impersonation attacks, read a lot of confidential content and even hijack web server user sessions. The bug was made public yesterday yet it took some companies like yahoo almost 24hours to fix it (was simply updating/downgrading openSSL on their servers or manually disabling the module causing the bug) and others still haven't reacted. Seeing so much info out on what can be done with this exploit just studied in 24hours makes me wonder how much of it was already thought out before public awareness and how much entities (hello NSA) have exploited this for the last 2 years (bug was deployed in 2012)
Heartbleed question:
+ Show Spoiler +Yeah holy shit wtf really?! How is this not everywhere...?! I mean at least here (on TL) where the average user actually has a vague idea of the implications of both sites with https that were impacted and the ones people didn't/don't realize are/were totally vulnerable for 2 years...?
Who knows who knew about this and for how long. Any and everyone who knows about it is pretty scary. I mean all the bank accounts that are compromised. I mean holy shit.... Ok, so could someone here calm my panic about heartbleed real quick or is that going to wildly disrupt everyone? (PM would be fine) so sorry to disturb, but this was the only place 'heartbleed' came up on my searches.
|
|
|
|
|
|