• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 13:16
CET 19:16
KST 03:16
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10[ASL20] Finals Preview: Arrival13
Community News
[TLMC] Fall/Winter 2025 Ladder Map Rotation12Weekly Cups (Nov 3-9): Clem Conquers in Canada4SC: Evo Complete - Ranked Ladder OPEN ALPHA8StarCraft, SC2, HotS, WC3, Returning to Blizzcon!45$5,000+ WardiTV 2025 Championship7
StarCraft 2
General
Mech is the composition that needs teleportation t RotterdaM "Serral is the GOAT, and it's not close" RSL Season 3 - RO16 Groups C & D Preview [TLMC] Fall/Winter 2025 Ladder Map Rotation TL.net Map Contest #21: Winners
Tourneys
RSL Revival: Season 3 Sparkling Tuna Cup - Weekly Open Tournament Constellation Cup - Main Event - Stellar Fest Tenacious Turtle Tussle Master Swan Open (Global Bronze-Master 2)
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 499 Chilling Adaptation Mutation # 498 Wheel of Misfortune|Cradle of Death Mutation # 497 Battle Haredened Mutation # 496 Endless Infection
Brood War
General
FlaSh on: Biggest Problem With SnOw's Playstyle What happened to TvZ on Retro? SnOw's ASL S20 Finals Review BW General Discussion Brood War web app to calculate unit interactions
Tourneys
[Megathread] Daily Proleagues Small VOD Thread 2.0 [BSL21] RO32 Group D - Sunday 21:00 CET [BSL21] RO32 Group C - Saturday 21:00 CET
Strategy
PvZ map balance Current Meta Simple Questions, Simple Answers How to stay on top of macro?
Other Games
General Games
Path of Exile Stormgate/Frost Giant Megathread Nintendo Switch Thread Clair Obscur - Expedition 33 Beyond All Reason
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread US Politics Mega-thread Artificial Intelligence Thread Canadian Politics Mega-thread
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread Korean Music Discussion Series you have seen recently...
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Dyadica Gospel – a Pulp No…
Hildegard
Coffee x Performance in Espo…
TrAiDoS
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Reality "theory" prov…
perfectspheres
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2028 users

The Big Programming Thread - Page 302

Forum Index > General Forum
Post a Reply
Prev 1 300 301 302 303 304 1032 Next
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.
Birdie
Profile Blog Joined August 2007
New Zealand4438 Posts
May 17 2013 03:08 GMT
#6021
On May 17 2013 12:04 CecilSunkure wrote:
Show nested quote +
On May 17 2013 11:53 Birdie wrote:
If I'm dealing with a text file where the last line is Baggins Bilbo;05-89378 with no space or newline character at the end of the file, how do I detect the "last character" which doesn't exist, so that I can cut that number off and place it into a variable?

I can do it with other lines using code such as
if(input[i] == '\n') {
temp[j] = '\0';
j = -1;
printf("Temp number: %s\n", temp);
strcpy(tempPhone.number, temp);
}

but that doesn't work when there IS no newline at the end of the number.

This is in C by the way.

I've tried using input[i] == NULL, which didn't work either (I would have thought it would because it's trying to get a character which doesn't exist). Perhaps I don't understand NULL properly yet.

If you're dealing with a text file try reading line by line, instead of with strcpy. Use fscanf. Looky here: http://www.randygaul.net/2013/02/07/fscanf-power/

I am reading line by line, using fgets, and then cycling through each character in the array using a for loop.
Red classic | A butterfly dreamed he was Zhuangzi | 4.5k, heading to 5k as support!
Abductedonut
Profile Blog Joined December 2010
United States324 Posts
May 17 2013 03:09 GMT
#6022
On May 17 2013 11:53 Birdie wrote:
If I'm dealing with a text file where the last line is Baggins Bilbo;05-89378 with no space or newline character at the end of the file, how do I detect the "last character" which doesn't exist, so that I can cut that number off and place it into a variable?

I can do it with other lines using code such as
if(input[i] == '\n') {
temp[j] = '\0';
j = -1;
printf("Temp number: %s\n", temp);
strcpy(tempPhone.number, temp);
}

but that doesn't work when there IS no newline at the end of the number.

This is in C by the way.

I've tried using input[i] == NULL, which didn't work either (I would have thought it would because it's trying to get a character which doesn't exist). Perhaps I don't understand NULL properly yet.


There is a proper answer to this, but try learning from the first answer:

Learn how to use a debugger. If you're on windows, you can use ollydbg or gdb or your IDE's debugger. Print out the address of input, and cruise on through memory and see how it is structured. One of the many uses of a debugger!

*The proper answer
I'm not 100% sure about this, but fgets or fscan or whatever it is you're using to read from the file reads until it gets an End-of-file marker. It SHOULD fill the the element after the "8" with a NULL.

I didn't look over your code honestly, but maybe if you change:

if(input[i] == '\n')

to

if(input[i] == '\n' || input[i] == NULL)

It might work.
Birdie
Profile Blog Joined August 2007
New Zealand4438 Posts
May 17 2013 03:14 GMT
#6023
I tried the || input[i] == NULL already. However, Cecil helped me on Skype and I think I have it sorted. Basically, because fgets is reading the line into a string, the number will already be terminated by a \0, hence temp will already have the number stored inside it (due to how I was already placing characters into temp).
Red classic | A butterfly dreamed he was Zhuangzi | 4.5k, heading to 5k as support!
Rotodyne
Profile Blog Joined July 2005
United States2263 Posts
Last Edited: 2013-05-17 03:17:18
May 17 2013 03:17 GMT
#6024

On May 17 2013 06:38 Bionicrm wrote:
I'm sort of new to web design. I've learned the basics of Python, HTML, CSS, and am still learning JavaScript (which is easy because concepts are similar to Python) via Codecademy.com.

I'm making a website, and when I zoom-in in the browser window, my little menu bar gets moved over and under the banner, a form is falling out of the border, and other crazy stuff. Are there ways that people prevent this?

When I zoom-in to TL, things just get bigger and fall off the screen, which is what should happen. Instead, things feel free to move all over on my site. Also, it is not visible on the web, as it's still in development (I view it from my computer), and I'm not sure if that has anything to do with it.


Having it on your computer instead of the web shouldn't make a difference. Like obesechicken said, it's probably how your CSS and HTML are set up. If you want a more specific answer I can take a look at your HTML/CSS if you post or PM me it.
I can only play starcraft when I am shit canned. IPXZERG is a god.
Mr. Wiggles
Profile Blog Joined August 2010
Canada5894 Posts
May 17 2013 03:42 GMT
#6025
This might be a bit of a random question, but what's the best way to get yourself familiar with the source code of a piece of software you've never seen before?

Basically, I'm doing work with a prof at my school over the summer, and he has an existing program he wants me to get familiar with. The problem I'm having though, is that the code base is a whole lot bigger than anything I've had experience with before (50000+ lines of code that are relevant), and it's quite complicated/sophisticated. Right now, I've just been going through some of the more important parts of the code, but it's been more haphazard than I'd like, and I don't feel like I'm being very efficient with my time.

So, I was basically wondering if there were any strategies for getting familiar with new code you haven't seen before, and what the most efficient way to become familiar with a large program is. Does anyone have any advice?

This is pretty much the first time that I've had to work with a large amount of code that I hadn't written myself. Most things I've encountered in my coursework or during my free time have been a lot smaller and easier to understand, so I'm finding this a little daunting, haha.

Any help would be appreciated :p
you gotta dance
Kambing
Profile Joined May 2010
United States1176 Posts
May 17 2013 04:35 GMT
#6026
On May 17 2013 12:42 Mr. Wiggles wrote:
This might be a bit of a random question, but what's the best way to get yourself familiar with the source code of a piece of software you've never seen before?

Basically, I'm doing work with a prof at my school over the summer, and he has an existing program he wants me to get familiar with. The problem I'm having though, is that the code base is a whole lot bigger than anything I've had experience with before (50000+ lines of code that are relevant), and it's quite complicated/sophisticated. Right now, I've just been going through some of the more important parts of the code, but it's been more haphazard than I'd like, and I don't feel like I'm being very efficient with my time.

So, I was basically wondering if there were any strategies for getting familiar with new code you haven't seen before, and what the most efficient way to become familiar with a large program is. Does anyone have any advice?

This is pretty much the first time that I've had to work with a large amount of code that I hadn't written myself. Most things I've encountered in my coursework or during my free time have been a lot smaller and easier to understand, so I'm finding this a little daunting, haha.

Any help would be appreciated :p


Few things to try:

(1) Create a high-level map of the codebase. Based off of what you know the program does and a quick, initial review of the code, split the logical units (e.g., source files) of the project up by functionality. For example, you can identify the parts of the code related to the GUI, the engine, serializing/de-serializing data to disk, etc.

(2) Test out a particular functionality (e.g., a widget that, when clicked, calculates a total) of the program. Then go to code and then, starting from main, walk through the code and trace through it until you can find what code is responsible for that behavior.

(3) If there are outstanding bugs in the codebase (ask your prof), make it a first priority to fix those bugs.

(4) Once you think you understand how a particular chunk of the project works, make a small modification to it to test your understanding.
waxypants
Profile Blog Joined September 2009
United States479 Posts
May 17 2013 04:45 GMT
#6027
On May 17 2013 12:14 Birdie wrote:
I tried the || input[i] == NULL already. However, Cecil helped me on Skype and I think I have it sorted. Basically, because fgets is reading the line into a string, the number will already be terminated by a \0, hence temp will already have the number stored inside it (due to how I was already placing characters into temp).


Also FYI there is feof.
http://www.cplusplus.com/reference/cstdio/feof/

"If the end-of-file is encountered while attempting to read a character, the eof indicator is set (feof)."
http://www.cplusplus.com/reference/cstdio/fgets/
Birdie
Profile Blog Joined August 2007
New Zealand4438 Posts
May 17 2013 05:01 GMT
#6028
On May 17 2013 13:45 waxypants wrote:
Show nested quote +
On May 17 2013 12:14 Birdie wrote:
I tried the || input[i] == NULL already. However, Cecil helped me on Skype and I think I have it sorted. Basically, because fgets is reading the line into a string, the number will already be terminated by a \0, hence temp will already have the number stored inside it (due to how I was already placing characters into temp).


Also FYI there is feof.
http://www.cplusplus.com/reference/cstdio/feof/

"If the end-of-file is encountered while attempting to read a character, the eof indicator is set (feof)."
http://www.cplusplus.com/reference/cstdio/fgets/

Yup I tried using that too, didn't work but I'll try again tonight or tomorrow. It's still not working properly T_T it works fine if I add a newline at the end of the file, but if it terminates the file at the end of a line then it won't run my if statement so the number is never read into temp. Very annoying.
Red classic | A butterfly dreamed he was Zhuangzi | 4.5k, heading to 5k as support!
Abductedonut
Profile Blog Joined December 2010
United States324 Posts
May 17 2013 05:39 GMT
#6029
On May 17 2013 14:01 Birdie wrote:
Show nested quote +
On May 17 2013 13:45 waxypants wrote:
On May 17 2013 12:14 Birdie wrote:
I tried the || input[i] == NULL already. However, Cecil helped me on Skype and I think I have it sorted. Basically, because fgets is reading the line into a string, the number will already be terminated by a \0, hence temp will already have the number stored inside it (due to how I was already placing characters into temp).


Also FYI there is feof.
http://www.cplusplus.com/reference/cstdio/feof/

"If the end-of-file is encountered while attempting to read a character, the eof indicator is set (feof)."
http://www.cplusplus.com/reference/cstdio/fgets/

Yup I tried using that too, didn't work but I'll try again tonight or tomorrow. It's still not working properly T_T it works fine if I add a newline at the end of the file, but if it terminates the file at the end of a line then it won't run my if statement so the number is never read into temp. Very annoying.


Send me your files and I'll take a look at your code. I could use the practice. It's in C yeah?
phar
Profile Joined August 2011
United States1080 Posts
Last Edited: 2013-05-17 07:29:21
May 17 2013 07:26 GMT
#6030
On May 17 2013 12:42 Mr. Wiggles wrote:
This might be a bit of a random question, but what's the best way to get yourself familiar with the source code of a piece of software you've never seen before?

Basically, I'm doing work with a prof at my school over the summer, and he has an existing program he wants me to get familiar with. The problem I'm having though, is that the code base is a whole lot bigger than anything I've had experience with before (50000+ lines of code that are relevant), and it's quite complicated/sophisticated. Right now, I've just been going through some of the more important parts of the code, but it's been more haphazard than I'd like, and I don't feel like I'm being very efficient with my time.

So, I was basically wondering if there were any strategies for getting familiar with new code you haven't seen before, and what the most efficient way to become familiar with a large program is. Does anyone have any advice?

This is pretty much the first time that I've had to work with a large amount of code that I hadn't written myself. Most things I've encountered in my coursework or during my free time have been a lot smaller and easier to understand, so I'm finding this a little daunting, haha.

Any help would be appreciated :p

50k lines of code from academia? My sincerest apologies

I remember having to spend a semester or so diving into a custom cpu simulator code base that had been built up by successive waves of PhD students. The resulting mass of code was about 75-100k lines, written in three languages (c, c++, and some perl), had no documentation, no adherence to any sort of style guide, no tests, and nobody left in the lab who even really knew what any significant part of it did.

It was like every new set of PhD students who came to the lab fought with the code until they could bolt on another frankenstein-ish module to do some new feature (speculative parallelism or what have you). Then they wrote their dissertation on whatever the fuck came out of the simulator without fully understanding the whole code base, left their random duct tape "enhancements," then graduated and left. Rinse & repeat for years.

That code was basically the most colossal waste of a semester in my 4-5 years at Uni. Unfortunate too, because the actual subject matter being studied was incredibly awesome.

Hopefully your experience will be better.



Also, just the experience of having to slog through a massive code base will get you some good insight. If you can get even a halfway decent execution of the 4 bullet points that someone wrote a few posts up, you'll be way ahead of the curve (assuming you're in undergrad). It's a necessary thing to learn, because the code out in the real world is on average only marginally better.
Who after all is today speaking about the destruction of the Armenians?
WindWolf
Profile Blog Joined July 2012
Sweden11767 Posts
May 17 2013 07:45 GMT
#6031
On May 17 2013 12:42 Mr. Wiggles wrote:
This might be a bit of a random question, but what's the best way to get yourself familiar with the source code of a piece of software you've never seen before?

Basically, I'm doing work with a prof at my school over the summer, and he has an existing program he wants me to get familiar with. The problem I'm having though, is that the code base is a whole lot bigger than anything I've had experience with before (50000+ lines of code that are relevant), and it's quite complicated/sophisticated. Right now, I've just been going through some of the more important parts of the code, but it's been more haphazard than I'd like, and I don't feel like I'm being very efficient with my time.

So, I was basically wondering if there were any strategies for getting familiar with new code you haven't seen before, and what the most efficient way to become familiar with a large program is. Does anyone have any advice?

This is pretty much the first time that I've had to work with a large amount of code that I hadn't written myself. Most things I've encountered in my coursework or during my free time have been a lot smaller and easier to understand, so I'm finding this a little daunting, haha.

Any help would be appreciated :p

It's really about taking your time and trying to understand the code one bit at a time and writing some code to prove that you understand that you get the idea.

In an earlier course of mine, I had to work with a framework that I didn't completely understand initially. But by taking it one bit at a time, looking at the source code and making some code to see that you understand what you're doing, you'll learn better that way I think.
EZ4ENCE
mcc
Profile Joined October 2010
Czech Republic4646 Posts
May 17 2013 07:49 GMT
#6032
On May 17 2013 12:42 Mr. Wiggles wrote:
This might be a bit of a random question, but what's the best way to get yourself familiar with the source code of a piece of software you've never seen before?

Basically, I'm doing work with a prof at my school over the summer, and he has an existing program he wants me to get familiar with. The problem I'm having though, is that the code base is a whole lot bigger than anything I've had experience with before (50000+ lines of code that are relevant), and it's quite complicated/sophisticated. Right now, I've just been going through some of the more important parts of the code, but it's been more haphazard than I'd like, and I don't feel like I'm being very efficient with my time.

So, I was basically wondering if there were any strategies for getting familiar with new code you haven't seen before, and what the most efficient way to become familiar with a large program is. Does anyone have any advice?

This is pretty much the first time that I've had to work with a large amount of code that I hadn't written myself. Most things I've encountered in my coursework or during my free time have been a lot smaller and easier to understand, so I'm finding this a little daunting, haha.

Any help would be appreciated :p

I personally hate going through the code just to understand it. So in such cases I ask someone for/assing myself some change I want to implement and with that goal go and look at the code until I know enough to make that specific modification correctly. And with many of these small tasks ( ideally increasing in complexity ) I gradually get to know the code base.
Abductedonut
Profile Blog Joined December 2010
United States324 Posts
Last Edited: 2013-05-17 08:43:47
May 17 2013 08:39 GMT
#6033
On May 17 2013 14:01 Birdie wrote:
Show nested quote +
On May 17 2013 13:45 waxypants wrote:
On May 17 2013 12:14 Birdie wrote:
I tried the || input[i] == NULL already. However, Cecil helped me on Skype and I think I have it sorted. Basically, because fgets is reading the line into a string, the number will already be terminated by a \0, hence temp will already have the number stored inside it (due to how I was already placing characters into temp).


Also FYI there is feof.
http://www.cplusplus.com/reference/cstdio/feof/

"If the end-of-file is encountered while attempting to read a character, the eof indicator is set (feof)."
http://www.cplusplus.com/reference/cstdio/fgets/

Yup I tried using that too, didn't work but I'll try again tonight or tomorrow. It's still not working properly T_T it works fine if I add a newline at the end of the file, but if it terminates the file at the end of a line then it won't run my if statement so the number is never read into temp. Very annoying.


Hi Birdie - I've confirmed that it should place a NULL char into your string after you call fgets() once it reaches the end of file marker. That isn't your problem.

My guess would be this:

- The second parameter to your fgets call is wrong
- If you're placing the string on the heap via malloc(), you could be corrupting the heap later without realizing.
- If you're allocating it on the stack via an array, the pointer to the array may change once you re-enter the function.

Of course, this is all speculation without seeing your code but my guess is it's one of those. Here's what you should do:
Call printf("%s",input);

IMMEDIATELY after the call to fgets(). If it prints the string "Baggins Bilbo;05-89378" and the if ( input[i] == null ) does not work, you're corrupting the string somehow. If it prints gibberish after the "8", then the second parameter of fgets is wrong.

*edit* To make this clearer, you sound like you're kinda newish to programming, and this seems like it's a memory allocation or off-by-one error which will be a waste of time for you to hunt down. The bug is probably much more advanced then you think.
waxypants
Profile Blog Joined September 2009
United States479 Posts
May 17 2013 10:46 GMT
#6034
On May 17 2013 17:39 Abductedonut wrote:
Show nested quote +
On May 17 2013 14:01 Birdie wrote:
On May 17 2013 13:45 waxypants wrote:
On May 17 2013 12:14 Birdie wrote:
I tried the || input[i] == NULL already. However, Cecil helped me on Skype and I think I have it sorted. Basically, because fgets is reading the line into a string, the number will already be terminated by a \0, hence temp will already have the number stored inside it (due to how I was already placing characters into temp).


Also FYI there is feof.
http://www.cplusplus.com/reference/cstdio/feof/

"If the end-of-file is encountered while attempting to read a character, the eof indicator is set (feof)."
http://www.cplusplus.com/reference/cstdio/fgets/

Yup I tried using that too, didn't work but I'll try again tonight or tomorrow. It's still not working properly T_T it works fine if I add a newline at the end of the file, but if it terminates the file at the end of a line then it won't run my if statement so the number is never read into temp. Very annoying.


Hi Birdie - I've confirmed that it should place a NULL char into your string after you call fgets() once it reaches the end of file marker. That isn't your problem.

My guess would be this:

- The second parameter to your fgets call is wrong
- If you're placing the string on the heap via malloc(), you could be corrupting the heap later without realizing.
- If you're allocating it on the stack via an array, the pointer to the array may change once you re-enter the function.

Of course, this is all speculation without seeing your code but my guess is it's one of those. Here's what you should do:
Call printf("%s",input);

IMMEDIATELY after the call to fgets(). If it prints the string "Baggins Bilbo;05-89378" and the if ( input[i] == null ) does not work, you're corrupting the string somehow. If it prints gibberish after the "8", then the second parameter of fgets is wrong.

*edit* To make this clearer, you sound like you're kinda newish to programming, and this seems like it's a memory allocation or off-by-one error which will be a waste of time for you to hunt down. The bug is probably much more advanced then you think.


Really it would be 1000x easier if OP gave a little more code instead of giving a tiny snippet saying it dint werk. Now that I look at it more closely, I can only guess what input, temp, i, and j really are. Its probably a super simple fix but I can't say exactly what it should be until I know more. Could be as simple as changing
if(input[i] == '\n')
to
if(input[i] == '\n' || input[i] == '\0')
.
Birdie
Profile Blog Joined August 2007
New Zealand4438 Posts
May 17 2013 10:47 GMT
#6035
On May 17 2013 19:46 waxypants wrote:
Show nested quote +
On May 17 2013 17:39 Abductedonut wrote:
On May 17 2013 14:01 Birdie wrote:
On May 17 2013 13:45 waxypants wrote:
On May 17 2013 12:14 Birdie wrote:
I tried the || input[i] == NULL already. However, Cecil helped me on Skype and I think I have it sorted. Basically, because fgets is reading the line into a string, the number will already be terminated by a \0, hence temp will already have the number stored inside it (due to how I was already placing characters into temp).


Also FYI there is feof.
http://www.cplusplus.com/reference/cstdio/feof/

"If the end-of-file is encountered while attempting to read a character, the eof indicator is set (feof)."
http://www.cplusplus.com/reference/cstdio/fgets/

Yup I tried using that too, didn't work but I'll try again tonight or tomorrow. It's still not working properly T_T it works fine if I add a newline at the end of the file, but if it terminates the file at the end of a line then it won't run my if statement so the number is never read into temp. Very annoying.


Hi Birdie - I've confirmed that it should place a NULL char into your string after you call fgets() once it reaches the end of file marker. That isn't your problem.

My guess would be this:

- The second parameter to your fgets call is wrong
- If you're placing the string on the heap via malloc(), you could be corrupting the heap later without realizing.
- If you're allocating it on the stack via an array, the pointer to the array may change once you re-enter the function.

Of course, this is all speculation without seeing your code but my guess is it's one of those. Here's what you should do:
Call printf("%s",input);

IMMEDIATELY after the call to fgets(). If it prints the string "Baggins Bilbo;05-89378" and the if ( input[i] == null ) does not work, you're corrupting the string somehow. If it prints gibberish after the "8", then the second parameter of fgets is wrong.

*edit* To make this clearer, you sound like you're kinda newish to programming, and this seems like it's a memory allocation or off-by-one error which will be a waste of time for you to hunt down. The bug is probably much more advanced then you think.


Really it would be 1000x easier if OP gave a little more code instead of giving a tiny snippet saying it dint werk. Now that I look at it more closely, I can only guess what input, temp, i, and j really are. Its probably a super simple fix but I can't say exactly what it should be until I know more. Could be as simple as changing
if(input[i] == '\n')
to
if(input[i] == '\n' || input[i] == '\0')
.

Tried that. Here's the pastebin:
http://pastebin.com/MrTCGtv3
Red classic | A butterfly dreamed he was Zhuangzi | 4.5k, heading to 5k as support!
teamamerica
Profile Blog Joined July 2010
United States958 Posts
May 17 2013 11:12 GMT
#6036
You should look at what strlen returns to see why you're never seeing the \0 character in your code.

Hint: how does strlen know it's reached the end of the string?
RIP GOMTV. RIP PROLEAGUE.
mcc
Profile Joined October 2010
Czech Republic4646 Posts
May 17 2013 11:23 GMT
#6037
On May 17 2013 20:12 teamamerica wrote:
You should look at what strlen returns to see why you're never seeing the \0 character in your code.

Hint: how does strlen know it's reached the end of the string?

Yep, that seems to be the suspicious part.

You should either use strlen value as termination flag along with '\n', or instead of using for-cycle use while and do not use strlen at all and test for '\n' and '\0' both.
Birdie
Profile Blog Joined August 2007
New Zealand4438 Posts
Last Edited: 2013-05-17 11:57:21
May 17 2013 11:57 GMT
#6038
On May 17 2013 20:23 mcc wrote:
Show nested quote +
On May 17 2013 20:12 teamamerica wrote:
You should look at what strlen returns to see why you're never seeing the \0 character in your code.

Hint: how does strlen know it's reached the end of the string?

Yep, that seems to be the suspicious part.

You should either use strlen value as termination flag along with '\n', or instead of using for-cycle use while and do not use strlen at all and test for '\n' and '\0' both.

I feel embarrassed for not remembering that as I already knew that T_T silly mistake. Thanks for the help guys, got it working!
Red classic | A butterfly dreamed he was Zhuangzi | 4.5k, heading to 5k as support!
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
May 17 2013 18:06 GMT
#6039
Ok, I got a question for you game programmers. It's not so much a game programming question, but a game design question.

I work in the wine industry, and I work for a large wine manufacturer. Us developers in the IT department build business solutions to business problems. None of us really have any actual game development experience. But we have this idea to build and release a mobile wine simulation game. And games of course are a whole different ballpark than business applications.

Any recommendations on how to develop a game, not so much from a programming perspective, but a management perspective? Are there any written guides out there that might get us started?
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
May 17 2013 18:58 GMT
#6040
On May 18 2013 03:06 enigmaticcam wrote:
Ok, I got a question for you game programmers. It's not so much a game programming question, but a game design question.

I work in the wine industry, and I work for a large wine manufacturer. Us developers in the IT department build business solutions to business problems. None of us really have any actual game development experience. But we have this idea to build and release a mobile wine simulation game. And games of course are a whole different ballpark than business applications.

Any recommendations on how to develop a game, not so much from a programming perspective, but a management perspective? Are there any written guides out there that might get us started?

Book: Rules of Play Game Design Fundamentals. Game design is way out of your area of expertise, so to make anything vaguely decent is going to take a huge amount of studying.
Prev 1 300 301 302 303 304 1032 Next
Please log in or register to reply.
Live Events Refresh
IPSL
17:00
Ro16 Group D
ZZZero vs rasowy
Napoleon vs KameZerg
Liquipedia
PSISTORM Gaming Misc
15:55
FSL teamleague CNvsASH, ASHvRR
Freeedom33
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Railgan 182
IndyStarCraft 112
BRAT_OK 35
MindelVK 29
EmSc Tv 10
StarCraft: Brood War
Britney 24531
Calm 2538
Shuttle 784
Stork 337
firebathero 292
Dewaltoss 123
Barracks 68
Rock 40
Shine 21
Dota 2
Gorgc5830
qojqva1713
Dendi963
Counter-Strike
ScreaM1071
byalli404
Heroes of the Storm
Khaldor535
Liquid`Hasu237
Other Games
Beastyqt573
DeMusliM291
Fuzer 228
Hui .217
Lowko209
Trikslyr49
CadenZie18
Organizations
Dota 2
PGL Dota 2 - Main Stream9203
Other Games
EGCTV565
gamesdonequick407
StarCraft 2
angryscii 24
EmSc Tv 10
EmSc2Tv 10
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 22 non-featured ]
StarCraft 2
• HappyZerGling 71
• HeavenSC 61
• printf 11
• LaughNgamezSOOP
• sooper7s
• AfreecaTV YouTube
• Migwel
• intothetv
• Kozan
• IndyKCrew
StarCraft: Brood War
• Airneanach44
• HerbMon 6
• Michael_bg 3
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• C_a_k_e 2520
• WagamamaTV367
• Ler78
League of Legends
• Nemesis2889
Other Games
• imaqtpie1125
• Shiphtur313
Upcoming Events
OSC
45m
davetesta15
BSL 21
1h 45m
Tarson vs Julia
Doodle vs OldBoy
eOnzErG vs WolFix
StRyKeR vs Aeternum
Sparkling Tuna Cup
15h 45m
RSL Revival
15h 45m
Reynor vs sOs
Maru vs Ryung
Kung Fu Cup
17h 45m
Cure vs herO
Reynor vs TBD
WardiTV Korean Royale
17h 45m
BSL 21
1d 1h
JDConan vs Semih
Dragon vs Dienmax
Tech vs NewOcean
TerrOr vs Artosis
IPSL
1d 1h
Dewalt vs WolFix
eOnzErG vs Bonyth
Replay Cast
1d 4h
Wardi Open
1d 17h
[ Show More ]
Monday Night Weeklies
1d 22h
WardiTV Korean Royale
2 days
BSL: GosuLeague
3 days
The PondCast
3 days
Replay Cast
4 days
RSL Revival
4 days
BSL: GosuLeague
5 days
RSL Revival
5 days
WardiTV Korean Royale
5 days
RSL Revival
6 days
WardiTV Korean Royale
6 days
IPSL
6 days
Julia vs Artosis
JDConan vs DragOn
Liquipedia Results

Completed

Proleague 2025-11-14
Stellar Fest: Constellation Cup
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
YSL S2
BSL Season 21
CSCL: Masked Kings S3
SLON Tour Season 2
RSL Revival: Season 3
META Madness #9
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.