• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 10:29
CET 16:29
KST 00:29
  • 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
TL.net Map Contest #21: Winners11Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10[ASL20] Finals Preview: Arrival13TL.net Map Contest #21: Voting12[ASL20] Ro4 Preview: Descent11
Community News
[TLMC] Fall/Winter 2025 Ladder Map Rotation6Weekly 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
[TLMC] Fall/Winter 2025 Ladder Map Rotation Mech is the composition that needs teleportation t Weekly Cups (Nov 3-9): Clem Conquers in Canada Craziest Micro Moments Of All Time? SC: Evo Complete - Ranked Ladder OPEN ALPHA
Tourneys
Constellation Cup - Main Event - Stellar Fest Tenacious Turtle Tussle Sparkling Tuna Cup - Weekly Open Tournament $5,000+ WardiTV 2025 Championship Merivale 8 Open - LAN - Stellar Fest
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
BW General Discussion FlaSh on: Biggest Problem With SnOw's Playstyle Terran 1:35 12 Gas Optimization BGH Auto Balance -> http://bghmmr.eu/ [ASL20] Ask the mapmakers — Drop your questions
Tourneys
[BSL21] RO32 Group D - Sunday 21:00 CET [BSL21] RO32 Group C - Saturday 21:00 CET [ASL20] Grand Finals [Megathread] Daily Proleagues
Strategy
Current Meta PvZ map balance How to stay on top of macro? Soma's 9 hatch build from ASL Game 2
Other Games
General Games
EVE Corporation Nintendo Switch Thread Stormgate/Frost Giant Megathread Should offensive tower rushing be viable in RTS games? Path of Exile
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
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread The Games Industry And ATVI
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
[Manga] One Piece Anime Discussion Thread Movie Discussion! 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: 1229 users

The Big Programming Thread - Page 115

Forum Index > General Forum
Post a Reply
Prev 1 113 114 115 116 117 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.
mmp
Profile Blog Joined April 2009
United States2130 Posts
February 09 2012 22:39 GMT
#2281
On February 09 2012 00:15 Inori wrote:
Show nested quote +
On February 08 2012 07:49 mmp wrote:
On February 07 2012 06:21 esotericc wrote:
Thanks for the advice, I think the one language every few months plan seems like the best course.

I think this is a poor course. Going into a degree program, you will be better served by depth of knowledge in a useful language, not shallow familiarity in irrelevant languages (you can adopt them later once you appreciate how irrelevant they are).

Python and C are both practical and relevant, more than any other languages I could recommend. Practical knowledge of Python will let you code up homework, class projects, and personal experiments quickly and with little headache. It's a decent scripting language to know, and is popular in software industry. Deep knowledge in C/C++ will make learning other languages a walk in the park, and is core to your education in computers. You'll do a lot better in compilers, computer languages, operating systems, distributed systems, parallel programming, and other classes that focus on low-level details if you start with an understanding of C.

When I wrote the suggestions, I assumed esotericc had extensive knowledge in programming since he said he freelancer for a few years. 2 months is more than enough when all you need to learn is syntax, idioms and distinctive features.

esotericc, since you actually don't have enough experience, I suggest ignoring my previous response and follow mmp post.

No beef.
I (λ (foo) (and (<3 foo) ( T_T foo) (RAGE foo) )) Starcraft
Kasha_Not_Kesha
Profile Blog Joined October 2011
United States71 Posts
February 10 2012 03:56 GMT
#2282
On February 10 2012 07:26 Frigo wrote:
Show nested quote +
On February 10 2012 06:47 Kasha_Not_Kesha wrote:
Programming books are very rarely worth the money. If you're trying to teach yourself how to program in a specific language, it's usually easier and cheaper (and more beneficial in the long run) to look up tutorials online. That's my opinion anyway =P

Read Clean Code: A Handbook of Agile Software Craftsmanship, I doubt you will find that in tutorials.


I'll look into it, thanks for the suggestion! I suppose I should have clarified that books explaining how to use a specific language (Like C#, which the guy I was responding to was looking for) are typically a waste of money. Conceptual books like the one you're talking about, or my Linear Data Structures book, can be uniquely helpful. =P
Human beings are literally made up of potential more than anything else.
silentsaint
Profile Joined September 2010
Germany540 Posts
February 10 2012 07:34 GMT
#2283
On February 10 2012 07:26 Frigo wrote:
Show nested quote +
On February 10 2012 06:47 Kasha_Not_Kesha wrote:
Programming books are very rarely worth the money. If you're trying to teach yourself how to program in a specific language, it's usually easier and cheaper (and more beneficial in the long run) to look up tutorials online. That's my opinion anyway =P

Read Clean Code: A Handbook of Agile Software Craftsmanship, I doubt you will find that in tutorials.


Thanks a lot. I'll look into it :-)
It really tied the room together.
Neelia
Profile Joined September 2010
Germany599 Posts
February 10 2012 14:19 GMT
#2284
On February 10 2012 06:31 silentsaint wrote:
Does anyone know a good book about c#?


C# in Depth (Jon Skeet) and CLR via C# (Jeffrey Richter)

If you know the basics.
shannn
Profile Blog Joined May 2010
Netherlands2891 Posts
February 10 2012 15:12 GMT
#2285
On February 10 2012 16:34 silentsaint wrote:
Show nested quote +
On February 10 2012 07:26 Frigo wrote:
On February 10 2012 06:47 Kasha_Not_Kesha wrote:
Programming books are very rarely worth the money. If you're trying to teach yourself how to program in a specific language, it's usually easier and cheaper (and more beneficial in the long run) to look up tutorials online. That's my opinion anyway =P

Read Clean Code: A Handbook of Agile Software Craftsmanship, I doubt you will find that in tutorials.


Thanks a lot. I'll look into it :-)

Totally need to read that book.

I got it as advice from my brother to read that and it really is beneficial to you :D
Also the Algorithm and Data structures mentioned in OP (or in another language like mine in Dutch) is also very good and imo a must read.
http://www.teamliquid.net/forum/viewpost.php?post_id=6321864 Epic post.
ranshaked
Profile Blog Joined August 2010
United States870 Posts
Last Edited: 2012-02-10 19:07:55
February 10 2012 18:55 GMT
#2286
C Programming
Hey guys, I'm trying to find an explaination on pointers etc. I keep getting errors like this
27 [Warning] passing arg 1 of `strcpy' makes pointer from integer without a cast


Basically what I'm trying to do is the following: Take a few words and associate them with a number. Then compare the words and print the highest word (by its number)

Right now since it's homework, I'm only allowed to use 1D array and not 2D. I'm struggling with understanding how when a user inputs a word, followed by a number IE: scanf("%s %d", WORD, number);
It keeps saving only the last word and number that was entered. When I use my if statement
if (word >mostword)
{mostword=word;
strcpy(lrgstword, word);

I'm not exactly understanding how this stuff works, and after researching for a few hours I've decided that most of it points toward C++ and using other commands that I'm not allowed to use.

Obviously the assignment is much more complicated than this, but this is kind of what I don't exactly understand.

Edit: It would be like entering the following:
Corolla 5000
Mercedes 50000
Corvette 40000

Then it saves those values to each word (car) and compares them. I cannot get it to save to a 1D array :/
Abductedonut
Profile Blog Joined December 2010
United States324 Posts
Last Edited: 2012-02-10 20:12:35
February 10 2012 20:03 GMT
#2287
On February 11 2012 03:55 ranshaked wrote:
C Programming
Hey guys, I'm trying to find an explaination on pointers etc. I keep getting errors like this
Show nested quote +
27 [Warning] passing arg 1 of `strcpy' makes pointer from integer without a cast


Basically what I'm trying to do is the following: Take a few words and associate them with a number. Then compare the words and print the highest word (by its number)

Right now since it's homework, I'm only allowed to use 1D array and not 2D. I'm struggling with understanding how when a user inputs a word, followed by a number IE: scanf("%s %d", WORD, number);
It keeps saving only the last word and number that was entered. When I use my if statement
if (word >mostword)
{mostword=word;
strcpy(lrgstword, word);

I'm not exactly understanding how this stuff works, and after researching for a few hours I've decided that most of it points toward C++ and using other commands that I'm not allowed to use.

Obviously the assignment is much more complicated than this, but this is kind of what I don't exactly understand.

Edit: It would be like entering the following:
Corolla 5000
Mercedes 50000
Corvette 40000

Then it saves those values to each word (car) and compares them. I cannot get it to save to a 1D array :/


This would be practically impossible in C the way your teacher wants it. I think your confusion is here:

There are two "types" of strings in C and C++. There are c strings, which are declared the following way"

- char[] kitten = "You suck";
- char* kitten = (char*)malloc(sizeof(char)*50);
kitten = "You Suck";

Then there are C++ strings, which are declared like this:

- string kitten = "You Suck";
- string kitten2("You Suck");

What's the difference? Non perfectly speaking, c strings are basically character arrays. They can be declared without including any sort of header file. The nice people are Bell Labs wrote a file with a bunch of functions that do common manipulations on c strings, such as the lovely strcpy() that you're using. That is in <string.h> or <cstring> if you're in c++. C strings are not objects, they are basically raw character data. C++ strings, on the other hand, are objects from a class called the string class. That's why you MUST include <string> whenever you declare them.

So now... if we want to store multiple C strings... then we must have an array of c strings. However, c strings are in themselves arrays, which means you're "sortof" using a double array. I'll write some example code for you to see what I mean.

+ Show Spoiler +


#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
char* stringCollection[5]; // An array of 5 character pointers....

for ( int i = 0; i < 5; i++ )
{
stringCollection[i] = (char*)malloc(sizeof(char)*20); // we're allocating memory to store stuff in our charater array.

// ghetto if statement just to make example clear, do not code like this....
if ( i == 0 )
stringCollection[i] = "Sup dawg how you doin??";
else if ( i == 1 )
stringCollection[i] = "Hello this is streing 2!!!";
else if ( i == 2 )
stringCollection[i] = "Yoyoyo i got the beats just call me dr. dre";
else if ( i == 3 )
stringCollection[i] = "C programming is AWESOME!";
else if ( i == 4 )
stringCollection[i] = "My Last String!!!";
}

// now let's print all this out!!!

for ( int i = 0; i < 5; i++ )
printf("String number %i: %s \n",i+1,stringCollection[i]);

// Ironically, we can access specific element ( i.e characters ) of each string by using double array notation!!
// That's because it is a double array!!!

char myChar = stringCollection[0][5]; // the fifth element of the 0th string in the collection... in other words the "a" in "sup dawg..."
char myChar2 = stringCollection[0][6]; // the sixth element of the 0th string in the collection...
printf("myChar is: %c \n",myChar);
printf("myChar2 is: %c \n",myChar2);

system("PAUSE");
return 0;
}



It would be almost impossible to store c string without using a double array. I can't think of anything. If you're using strings, however, it's TECHNICALLY an array of objects and not a double array.

One way to do so is this:
- string myString[3] = {"Audi", "BMW", "Ford"};

That should give you a good start! I think your problem with strcpy(), btw, is that you're passing an integer for the first argument. You must pass a char* as the first argument. Ask yourself of what type "lrgstword" is. Hope this gives you some insight. Let me know if you have more questions.

*edit* For those of you who think you're total ballers and take my code literally and point out that I go past my declared buffer length... I know this. It's just an example, that's not code for the pentagon.
ranshaked
Profile Blog Joined August 2010
United States870 Posts
February 10 2012 20:08 GMT
#2288
On February 11 2012 05:03 Abductedonut wrote:
Show nested quote +
On February 11 2012 03:55 ranshaked wrote:
C Programming
Hey guys, I'm trying to find an explaination on pointers etc. I keep getting errors like this
27 [Warning] passing arg 1 of `strcpy' makes pointer from integer without a cast


Basically what I'm trying to do is the following: Take a few words and associate them with a number. Then compare the words and print the highest word (by its number)

Right now since it's homework, I'm only allowed to use 1D array and not 2D. I'm struggling with understanding how when a user inputs a word, followed by a number IE: scanf("%s %d", WORD, number);
It keeps saving only the last word and number that was entered. When I use my if statement
if (word >mostword)
{mostword=word;
strcpy(lrgstword, word);

I'm not exactly understanding how this stuff works, and after researching for a few hours I've decided that most of it points toward C++ and using other commands that I'm not allowed to use.

Obviously the assignment is much more complicated than this, but this is kind of what I don't exactly understand.

Edit: It would be like entering the following:
Corolla 5000
Mercedes 50000
Corvette 40000

Then it saves those values to each word (car) and compares them. I cannot get it to save to a 1D array :/


This would be practically impossible in C the way your teacher wants it. I think your confusion is here:

There are two "types" of strings in C and C++. There are c strings, which are declared the following way"

- char[] kitten = "You suck";
- char* kitten = (char*)malloc(sizeof(char)*50);
kitten = "You Suck";

Then there are C++ strings, which are declared like this:

- string kitten = "You Suck";
- string kitten2("You Suck");

What's the difference? Non perfectly speaking, c strings are basically character arrays. They can be declared without including any sort of header file. The nice people are Bell Labs wrote a file with a bunch of functions that do common manipulations on c strings, such as the lovely strcpy() that you're using. That is in <string.h> or <cstring> if you're in c++. C strings are not objects, they are basically raw character data. C++ strings, on the other hand, are objects from a class called the string class. That's why you MUST include <string> whenever you declare them.

So now... if we want to store multiple C strings... then we must have an array of c strings. However, c strings are in themselves arrays, which means you're "sortof" using a double array. I'll write some example code for you to see what I mean.

+ Show Spoiler +


#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]
{
char* stringCollection[5]; // An array of 5 character pointers....

for ( int i = 0; i < 5; i++ )
{
stringCollection[i] = (char*)malloc(sizeof(char)*20); // we're allocating memory to store stuff in our charater array.

// ghetto if statement just to make example clear, do not code like this....
if ( i == 0 )
stringCollection[i] = "Sup dawg how you doin??";
else if ( i == 1 )
stringCollection[i] = "Hello this is streing 2!!!";
else if ( i == 2 )
stringCollection[i] = "Yoyoyo i got the beats just call me dr. dre";
else if ( i == 3 )
stringCollection[i] = "C programming is AWESOME!";
else if ( i == 4 )
stringCollection[i] = "My Last String!!!";
}

// now let's print all this out!!!

for ( int i = 0; i < 5; i++ )
printf("String number %i: %s \n",i+1,stringCollection[i];

// Ironically, we can access specific element ( i.e characters ) of each string by using double array notation!!
// That's because it is a double array!!!

char myChar = stringCollection[0][5]; // the fifth element of the 0th string in the collection... in other words the "a" in "sup dawg..."
char myChar2 = stringCollection[0][6]; // the sixth element of the 0th string in the collection...
printf("myChar is: %c \n",myChar);
printf("myChar2 is: %c \n",myChar2);

system("PAUSE");
return 0;
}



It would be almost impossible to store c string without using a double array. I can't think of anything. If you're using strings, however, it's TECHNICALLY an array of objects and not a double array.

One way to do so is this:
- string myString[3] = {"Audi", "BMW", "Ford"};

That should give you a good start! I think your problem with strcpy(), btw, is that you're passing an integer for the first argument. You must pass a char* as the first argument. Ask yourself of what type "lrgstword" is. Hope this gives you some insight. Let me know if you have more questions.

Thank you very much, I'll continue to read this. I knew that you can't force an integer to a string, but that's how he wanted it? I'm not quite sure. The actual homework question is pretty basic, but the way it is written and the example he gave doesn't even work. We've never used char * in any examples, which is partially why I'm confused.
+ Show Spoiler +
MAXEV=0;
char SNAME[20]
for (i=0;i<n;i++{
scanf("%s", &SNAME)//STATENAME//
scanf("d", &STATELECTORALVOTES); //stateelectoralvotes//
if STATEELECTORALVOTES > MAXEV
{MAXEV=STATELECTORALVOTES
strcpy(maxsname, sname)}

printf("sname")


That was a "piece" of the code that he wrote down as we went over it in class. It doesn't work at all
tofucake
Profile Blog Joined October 2009
Hyrule19151 Posts
February 10 2012 20:32 GMT
#2289
that's because it's pseudocode.

Also, you can convert strings/integers with atoi and itoa.
Liquipediaasante sana squash banana
ranshaked
Profile Blog Joined August 2010
United States870 Posts
February 10 2012 20:50 GMT
#2290
On February 11 2012 05:32 tofucake wrote:
that's because it's pseudocode.

Also, you can convert strings/integers with atoi and itoa.

We aren't allowed to use that stuff. This is why I'm so confused.
tofucake
Profile Blog Joined October 2009
Hyrule19151 Posts
February 10 2012 21:05 GMT
#2291
What, you're not allowed to use pseudocode, or conversion functions?
Liquipediaasante sana squash banana
zzdd
Profile Joined December 2010
United States484 Posts
February 10 2012 23:34 GMT
#2292
On February 11 2012 05:08 ranshaked wrote:
Show nested quote +
On February 11 2012 05:03 Abductedonut wrote:
On February 11 2012 03:55 ranshaked wrote:
C Programming
Hey guys, I'm trying to find an explaination on pointers etc. I keep getting errors like this
27 [Warning] passing arg 1 of `strcpy' makes pointer from integer without a cast


Basically what I'm trying to do is the following: Take a few words and associate them with a number. Then compare the words and print the highest word (by its number)

Right now since it's homework, I'm only allowed to use 1D array and not 2D. I'm struggling with understanding how when a user inputs a word, followed by a number IE: scanf("%s %d", WORD, number);
It keeps saving only the last word and number that was entered. When I use my if statement
if (word >mostword)
{mostword=word;
strcpy(lrgstword, word);

I'm not exactly understanding how this stuff works, and after researching for a few hours I've decided that most of it points toward C++ and using other commands that I'm not allowed to use.

Obviously the assignment is much more complicated than this, but this is kind of what I don't exactly understand.

Edit: It would be like entering the following:
Corolla 5000
Mercedes 50000
Corvette 40000

Then it saves those values to each word (car) and compares them. I cannot get it to save to a 1D array :/


This would be practically impossible in C the way your teacher wants it. I think your confusion is here:

There are two "types" of strings in C and C++. There are c strings, which are declared the following way"

- char[] kitten = "You suck";
- char* kitten = (char*)malloc(sizeof(char)*50);
kitten = "You Suck";

Then there are C++ strings, which are declared like this:

- string kitten = "You Suck";
- string kitten2("You Suck");

What's the difference? Non perfectly speaking, c strings are basically character arrays. They can be declared without including any sort of header file. The nice people are Bell Labs wrote a file with a bunch of functions that do common manipulations on c strings, such as the lovely strcpy() that you're using. That is in <string.h> or <cstring> if you're in c++. C strings are not objects, they are basically raw character data. C++ strings, on the other hand, are objects from a class called the string class. That's why you MUST include <string> whenever you declare them.

So now... if we want to store multiple C strings... then we must have an array of c strings. However, c strings are in themselves arrays, which means you're "sortof" using a double array. I'll write some example code for you to see what I mean.

+ Show Spoiler +


#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]
{
char* stringCollection[5]; // An array of 5 character pointers....

for ( int i = 0; i < 5; i++ )
{
stringCollection[i] = (char*)malloc(sizeof(char)*20); // we're allocating memory to store stuff in our charater array.

// ghetto if statement just to make example clear, do not code like this....
if ( i == 0 )
stringCollection[i] = "Sup dawg how you doin??";
else if ( i == 1 )
stringCollection[i] = "Hello this is streing 2!!!";
else if ( i == 2 )
stringCollection[i] = "Yoyoyo i got the beats just call me dr. dre";
else if ( i == 3 )
stringCollection[i] = "C programming is AWESOME!";
else if ( i == 4 )
stringCollection[i] = "My Last String!!!";
}

// now let's print all this out!!!

for ( int i = 0; i < 5; i++ )
printf("String number %i: %s \n",i+1,stringCollection[i];

// Ironically, we can access specific element ( i.e characters ) of each string by using double array notation!!
// That's because it is a double array!!!

char myChar = stringCollection[0][5]; // the fifth element of the 0th string in the collection... in other words the "a" in "sup dawg..."
char myChar2 = stringCollection[0][6]; // the sixth element of the 0th string in the collection...
printf("myChar is: %c \n",myChar);
printf("myChar2 is: %c \n",myChar2);

system("PAUSE");
return 0;
}



It would be almost impossible to store c string without using a double array. I can't think of anything. If you're using strings, however, it's TECHNICALLY an array of objects and not a double array.

One way to do so is this:
- string myString[3] = {"Audi", "BMW", "Ford"};

That should give you a good start! I think your problem with strcpy(), btw, is that you're passing an integer for the first argument. You must pass a char* as the first argument. Ask yourself of what type "lrgstword" is. Hope this gives you some insight. Let me know if you have more questions.

Thank you very much, I'll continue to read this. I knew that you can't force an integer to a string, but that's how he wanted it? I'm not quite sure. The actual homework question is pretty basic, but the way it is written and the example he gave doesn't even work. We've never used char * in any examples, which is partially why I'm confused.
+ Show Spoiler +
MAXEV=0;
char SNAME[20]
for (i=0;i<n;i++{
scanf("%s", &SNAME)//STATENAME//
scanf("d", &STATELECTORALVOTES); //stateelectoralvotes//
if STATEELECTORALVOTES > MAXEV
{MAXEV=STATELECTORALVOTES
strcpy(maxsname, sname)}

printf("sname")


That was a "piece" of the code that he wrote down as we went over it in class. It doesn't work at all

I'm not sure you understand the problem correctly. You want to find the name with the highest number and can ignore anything else. You don't need a 2d array. Just one that can hold the name with the high number.

Also with scanf your arguments are expected to be pointers so it should be scanf("%s, %d", &word, &number). The number received should be the comparison not the word.

if(number > greatestNumber){
greatestNumber = number;
strcopy(lrgstword, word);
}

word should be a char array. Just do char word[100] for simplicity.

If the number passed isn't greater than the greatest number than you can ignore the name and number completely.

ShadowWolf
Profile Joined March 2010
United States197 Posts
February 10 2012 23:47 GMT
#2293
FWIW, a 2D array and an array of char*s are not the same. While, especially in terms of syntax, they are very similar there are still some major differences in how they can be initialized and how they are represented 'under the covers'. See http://c-faq.com/aryptr/aryptr2.html for more information on why this is true. Therefore, a 1D array of pointers to char should satisfy the homework assignment completely.

Also, you should clarify to yourself whether the assignment requires that you keep a list of all previously entered words or only the word entered with the highest number. That makes a big difference in how you'll approach the problem.

Good luck!
Bobbias
Profile Blog Joined March 2008
Canada1373 Posts
February 10 2012 23:55 GMT
#2294
What he's describing is basically keeping a "running maximum" for the input number, and copying the word you typed on the same line over into a variable whenever the number is larger than the previous one. Instead of storing each input and acting on them after, this is a sort of a filter that simply throws out anything smaller than the current largest number and saves the number and the associated word when it finds an input that is larger than it's current contents.

Personally my first instinct would have been to create a 2 dimensional array, feed each new line in and then process, but with the limitations you have, what he's describing there sounds like a pretty good way to go about it.
tec27
Profile Blog Joined June 2004
United States3702 Posts
February 11 2012 00:57 GMT
#2295
On February 11 2012 08:55 Bobbias wrote:
What he's describing is basically keeping a "running maximum" for the input number, and copying the word you typed on the same line over into a variable whenever the number is larger than the previous one. Instead of storing each input and acting on them after, this is a sort of a filter that simply throws out anything smaller than the current largest number and saves the number and the associated word when it finds an input that is larger than it's current contents.

Personally my first instinct would have been to create a 2 dimensional array, feed each new line in and then process, but with the limitations you have, what he's describing there sounds like a pretty good way to go about it.

Its not just a pretty good way to go about it, its pretty much the *best* way to go about it. It avoids double-iterating the list and avoids allocating a large chunk of memory to store all the strings that it will only look at once. Much better than the naive approach, especially for large input sets.
Can you jam with the console cowboys in cyberspace?
Serthius
Profile Joined December 2010
Samoa226 Posts
February 11 2012 01:03 GMT
#2296
On February 10 2012 06:47 Kasha_Not_Kesha wrote:
Programming books are very rarely worth the money. If you're trying to teach yourself how to program in a specific language, it's usually easier and cheaper (and more beneficial in the long run) to look up tutorials online. That's my opinion anyway =P


I disagree. I find reading a book tends to give you a more complete picture. Whenever I try to learn only through online tutorials I get the feeling I'm missing something, and I usually am.
zzdd
Profile Joined December 2010
United States484 Posts
February 11 2012 07:23 GMT
#2297
On February 11 2012 09:57 tec27 wrote:
Show nested quote +
On February 11 2012 08:55 Bobbias wrote:
What he's describing is basically keeping a "running maximum" for the input number, and copying the word you typed on the same line over into a variable whenever the number is larger than the previous one. Instead of storing each input and acting on them after, this is a sort of a filter that simply throws out anything smaller than the current largest number and saves the number and the associated word when it finds an input that is larger than it's current contents.

Personally my first instinct would have been to create a 2 dimensional array, feed each new line in and then process, but with the limitations you have, what he's describing there sounds like a pretty good way to go about it.

Its not just a pretty good way to go about it, its pretty much the *best* way to go about it. It avoids double-iterating the list and avoids allocating a large chunk of memory to store all the strings that it will only look at once. Much better than the naive approach, especially for large input sets.

Agree, I have to question the programming knowledge of anyone that though using a 2d array would be better and easier.
Weson
Profile Blog Joined December 2010
Iceland1032 Posts
February 11 2012 12:33 GMT
#2298
On February 10 2012 23:19 Neelia wrote:
Show nested quote +
On February 10 2012 06:31 silentsaint wrote:
Does anyone know a good book about c#?


C# in Depth (Jon Skeet) and CLR via C# (Jeffrey Richter)

If you know the basics.

I have How to program Visual C# 2010 by Deitel. I think it's the best programming book i've ever had. Lots of exercises and you get access to their online extras. Really recommend it
"!@€#" - as some guy said
billy5000
Profile Blog Joined December 2010
United States865 Posts
February 11 2012 16:23 GMT
#2299
speaking of books, can anybody recommend me a good intro java book, specifically with numerous exercises? the book we use for class does in fact has tons exercises, but no answers (wtf??). Some of them you can check for yourself, which i have no problems with, but other questions ask for a fragment code from a more complicated whole and such.
Tiger got to hunt, bird got to fly; Man got to sit and wonder, 'Why, why, why?' Tiger got to sleep, bird got to land; Man got to tell himself he understand. Vonnegut
Shraft
Profile Joined October 2010
Sweden701 Posts
February 11 2012 16:41 GMT
#2300
On February 12 2012 01:23 billy5000 wrote:
speaking of books, can anybody recommend me a good intro java book, specifically with numerous exercises? the book we use for class does in fact has tons exercises, but no answers (wtf??). Some of them you can check for yourself, which i have no problems with, but other questions ask for a fragment code from a more complicated whole and such.

If you are new to programming I can recommend Objects First with Java. It's the book that we're using for our introductory programming course. It is really pedagogic and it has tons of exercises in it (no answers though). I've never used another programming book so I don't have much to compare it to, but I think that the book is very good for a beginner and I am very satisfied with it.
Prev 1 113 114 115 116 117 1032 Next
Please log in or register to reply.
Live Events Refresh
OSC
11:30
Mid Season Playoffs
Krystianer vs PercivalLIVE!
WardiTV1063
TKL 199
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
TKL 199
SteadfastSC 109
Rex 91
StarCraft: Brood War
Calm 3367
Bisu 2918
Rain 2430
Hyuk 1473
Horang2 984
Flash 514
Soma 498
Stork 393
Rush 303
Soulkey 121
[ Show more ]
Backho 114
Barracks 58
sas.Sziky 46
hero 38
Aegong 27
zelot 22
sSak 21
Terrorterran 20
Rock 19
Killer 16
Dota 2
Gorgc3152
qojqva2018
Dendi1105
BananaSlamJamma123
XcaliburYe100
Other Games
hiko638
Sick526
DeMusliM442
Hui .346
Fuzer 199
Mew2King94
QueenE50
Organizations
StarCraft: Brood War
Kim Chul Min (afreeca) 9
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• poizon28 22
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• HerbMon 10
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• C_a_k_e 3021
• WagamamaTV453
League of Legends
• Nemesis4037
• TFBlade977
Upcoming Events
Tenacious Turtle Tussle
7h 32m
The PondCast
18h 32m
RSL Revival
18h 32m
Solar vs Zoun
MaxPax vs Bunny
Kung Fu Cup
20h 32m
WardiTV Korean Royale
20h 32m
PiGosaur Monday
1d 9h
RSL Revival
1d 18h
Classic vs Creator
Cure vs TriGGeR
Kung Fu Cup
1d 20h
CranKy Ducklings
2 days
RSL Revival
2 days
herO vs Gerald
ByuN vs SHIN
[ Show More ]
Kung Fu Cup
2 days
IPSL
3 days
ZZZero vs rasowy
Napoleon vs KameZerg
BSL 21
3 days
Tarson vs Julia
Doodle vs OldBoy
eOnzErG vs WolFix
StRyKeR vs Aeternum
Sparkling Tuna Cup
3 days
RSL Revival
3 days
Reynor vs sOs
Maru vs Ryung
Kung Fu Cup
3 days
WardiTV Korean Royale
3 days
BSL 21
4 days
JDConan vs Semih
Dragon vs Dienmax
Tech vs NewOcean
TerrOr vs Artosis
IPSL
4 days
Dewalt vs WolFix
eOnzErG vs Bonyth
Wardi Open
4 days
Monday Night Weeklies
5 days
WardiTV Korean Royale
5 days
The PondCast
6 days
Liquipedia Results

Completed

Proleague 2025-11-07
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
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
BLAST Open Fall Qual

Upcoming

SLON Tour Season 2
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
RSL Revival: Season 3
META Madness #9
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...

Disclosure: This page contains affiliate marketing links that support TLnet.

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.