Competitive/Collaborative Programming Class

ICPC Computer Programming Contest Prep

Problem Solving in Computer Science

Spring 2015 -- CSC 2700 Section 01

[Isaac's Home Page ]  [Mailing List ]  [Class Page ]  [Printable ]  
 Home
 Outline/Policy
 Summary
 Approach
 References
 Discussion
 
 Homework
   View
   Upload
 
 Problems:
   Categories
   Guidelines
   Solve
 
 UVA
   Archive
   Archive Mirror
   LSU
   Problems
 
 Coding
   Tips
 
 Contests:
   NA Qualifier
   Regional
 
 Extra:
   Grades
   Names (you should know)
 
 
 
 Class:
   CSC 2700 Section 01
   Tureaud 116
   Tuesday
   6:30 PM - 8:30 PM
 
 Previous:
   2013 Fall
   2013 Spring
   2012 Fall
   2012 Spring
   2011 Fall
 

Tips

  • C related
    • Read an entire line (ignoring whitespace at begining and end of line): cnt = scanf("%[^\n]\n",str);
      • cnt has the following value possibilities:
        • 0 - blank line read
        • EOF - end of file encountered
        • positive number - characters read
      • %[^\n] is a format regular expression that says to get from beginning of line (^) until end of line (\n)
      • The second \n after the close bracket consumes the end of line
      • Note that this is vulenerable to overflow. If the line length is greater than str is declared for, it will continue to keep going (buffer overflow)
      • Note that white space at begining and end of line are lost
    • A better alternative that does not have a buffer overflow is: cnt = scanf("%10000[^\n]\n",str);
      • This assumes that str was declared to be 10000 characters long and will read a max of 10000 caracters
    • gets alternative that does not have stack overflow issues





[ Powered by Red Hat Linux ] [ Powered by Apache ] [ Powered by PHP ]

The statements and opinions included in these pages are those of only. Any statements and opinions included in these pages are not those of Louisiana State University or the LSU Board of Supervisors.
© 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015