The Big Programming Thread - Page 851
| Forum Index > General Forum |
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. | ||
|
Deleted User 173346
16169 Posts
| ||
|
Manit0u
Poland17720 Posts
On February 23 2017 14:14 plasmidghost wrote: (Hope this is allowed) I'll give someone an up to $10 Steam game of their choice if they can help me get my C programs working since it's not really fair of me to ask for someone to help me with code this complex for free This code is not very complex... | ||
|
Acrofales
Spain18259 Posts
So take the $10 and laugh your way to the bank ![]() | ||
|
waffelz
Germany711 Posts
![]() | ||
|
tofucake
Hyrule19202 Posts
| ||
|
Deleted User 3420
24492 Posts
so, a string is a character array. A string pointer points to an index of that array, and the string is all the indexes that have characters until the null character the null character is '\0' a string that is a character array where index 0 is '\0' is an empty string, which is not the same as the string being null (uninitialized) and then... what is happening when you say String = '' (these are single quotes with nothing inbetween). If someone passed my method a string of 2 empty quotes with nothing inbetween, how do I check for that? I seem to be able to pass it into my program, and have no way to check for it. If I try to simply check for '', the compiler gives me an error about an empty character constant also please correct any inaccuracies/misconceptions I have about strings thank you! | ||
|
Nesserev
Belgium2760 Posts
| ||
|
Deleted User 3420
24492 Posts
On February 23 2017 23:59 Nesserev wrote: There is no empty character constant. So, you get an error, because the compiler recognizes that this isn't a valid token. Well, I have an assignment where I pass in a character array and it centers the character array(string) between a specified number of spaces I pass in '' (empty character), and my program behaves very strangely. So I was wondering how to look for that. i guess as far as user input goes there would be no way for a user to input an empty character so there is no point in worrying about it? | ||
|
Nesserev
Belgium2760 Posts
| ||
|
Deleted User 3420
24492 Posts
So, to check for it, I would literally check for '\'' ? | ||
|
Acrofales
Spain18259 Posts
On February 24 2017 00:25 travis wrote: oh, so the characters you are passing are \ and ' ? So, to check for it, I would literally check for '\'' ? No. You're misunderstanding how characters work. The character that you are passing is '. However, you are inputting this from the command line (I presume) using scanf or something similar? If so, anything you input there is already escaped. If you need to write it in your source code, you would need to escape that character yourself, and thus you would write:
These are not two chars. It is one single char (apostrophe), but because ' itself has a very specific meaning in C code, you need to escape it when you want it to be seen as that char, and not as meaning something to the compiler (specifically, the opening or closing of a char). The same goes for any other special character, such as #, " or \ itself. Empty char is not defined. So if you try to write:
you should get a compiler error (or rather, a parser error, but forget about that distinction). | ||
|
Deleted User 3420
24492 Posts
fixed mah problems | ||
|
Blisse
Canada3710 Posts
On February 23 2017 16:29 plasmidghost wrote: Oh, sorry, I didn't even see that you had edited in more information, thank you for the help I wanted to try this because I didn't take the class but I watched my friends struggle with a similar assignment which looked cool. Unfortunately compiles but completely untested because Windows Bash doesn't support mkfifo, but this should give an idea of clearer code. There's a couple mistakes like where I use data.value instead of buffer, and probably using the string functions incorrectly. Also changed from 10 to 6 with a variable but didn't correct in all places cos can't run lol http://pastebin.com/8qCh1063 | ||
|
WarSame
Canada1950 Posts
On February 23 2017 15:37 Nesserev wrote: Uh, that shouldn't happen by default though. Usually what you have to do is: - specify which network interface(s) to listen behind - change your firewall settings - find out your local IP address Some web servers seem to just listen on all available network interfaces by default... which isn't a good thing. Using 'localhost' as the default network interface, and being explicit about other network interfaces is much more secure. Also, did you have your firewall set up? My firewall is definitely set up. I'm not 100% sure what a network interface is, but my friend did have to enter my "IP"(not an actual IP) on my LAN, so that may be what you mean. We also had to allow the connection through our firewalls, IIRC when we were first setting up the server. And yeah, we found our local IP address by ipconfig, so he'd type in "http://192.168.0.16:3000" to access my server on port 3000. Could you clarify what a network interface is? Google isn't really making sense to me. | ||
|
Nesserev
Belgium2760 Posts
| ||
|
meatpudding
Australia520 Posts
On February 23 2017 10:57 plasmidghost wrote: With that specific output I was just testing to see if it would take enter keystrokes as characters I replaced all the size one arrays to just be an int as well as changing my for loops for accepting characters to be fgets statements and it now partially works ![]() Current server code: pastebin.com Current client code: pastebin.com Just having a quick look... This seems to be a huge problem if(inst.outchar1[i] < 'a' && inst.outchar1[i] > 'z') Edit: Also this else if(inst.outchar1[i] = 'a' || 'e' || 'i' || 'o' || 'u') Shoulde lok more like this else if(inst.outchar1[i] == 'a' || inst.outchar1[i] == 'e' || inst.outchar1[i] == 'i' || inst.outchar1[i] == 'o' || inst.outchar1[i] == 'u') Note the = is the assignment operator and == is the equality operator. Each individual statement will be assessed, so you are asking "is this equal" OR "is 'e' true/nonzero" etc. | ||
|
Deleted User 3420
24492 Posts
the problem is that I decremented my paragraph_number by one in one of my functions, but not the other in other news, this class is insane. this workload is actually just crazy + Show Spoiler + working on a project, having some woes this is way harder than java was I can't post my code but maybe I can describe it and someone will have an idea what is going on I have document structures, which contain an array of paragraph structures. Paragraphs hold paragraph 2 dimensional arrays. These arrays are "lines" where each line is a string. In each paragraph structure, there is a variable that holds the amount of lines in that paragraph, and I increment it when I add lines. Now, I have a function
You add a line at that line number, in that paragraph, where the text is *new_line. This function seems to work fine. I have another function
this function adds *new_line text as a new line at the END of the lines of that paragraph. To implement this, I start with
My intention is to pass line_number to the first method (add_line_after), because it inserts the line at whatever line number you say, and this line number should be the last line. (0, then 1, then 2, etc) Now here is the part I don't understand. It's not working. It's not working because it's saying that the line number is 0 every time. I am checking with a print statement. But I also have a print statement to check the line number value in my add_line_after function. And in *THAT* function, it is incrementing the line number each time. It says (0, then 1, then 2, etc). If I try to do append_line 3 times my print statements say "010203" But they are both printing the value ofthe same variable.. right? or not? god does this have something to do with C's pass by value bullshit and I am not using pointers correctly? this is so complicated ![]() I really thought doc->paragraphs[paragraph_number].number_of_lines would be pointing to the same thing each time can you guys heeeeeeeeelp me | ||
|
Blisse
Canada3710 Posts
Been meaning to do foobar2000 development for a while, but never got into it because of the high barrier to entry, so I finally sat down yesterday to plow through getting a build to... build. So many Visual Studio issues to work through, like hardcoded library paths, hardcoded build scripts, missing libs... and the code quality is also so poor. Like seriously, single 3000-line file. the nice part is refactoring stuff will help me learn what's what. | ||
|
Deleted User 3420
24492 Posts
you guys *are* my rubber ducky also how do C developers not go crazy staring at this shit | ||
|
emperorchampion
Canada9496 Posts
On February 25 2017 06:15 travis wrote: there has been like 20 times today ive typed stuff out into this submit form and then erased it because I figured out my problem as I was typing it you guys *are* my rubber ducky also how do C developers not go crazy staring at this shit That's the secret, they're all crazy | ||
| ||

![[image loading]](http://i.imgur.com/5K73Bo7.png)
![[image loading]](http://i.imgur.com/0K9gEbq.png)
