Theme Graphic
Theme Graphic

Protein Folding

Triumphs and woes of a PhD student working on the protein folding problem. Fortran 77 (yes, really), Message Passing Interface (MPI), C,...

Subscribe

Author

I'm an ex-games programmer, now a PhD student at Leeds University studying the protein folding problem. Read my books "MiniBasic, how to write a script interpreter" and "Basic Algoritms". You can also read my MRes thesis on fuzzy logic trees.

Archive

Tags

Posted on Friday, August 07, 2009 at 6:06 AM

detab utility in C

Here's a detab utility.

This should bread and butter code. In fact it is tricky to ensure that a malicious user cannot cause a buffer overrun. Hence the maxmemory() routine. getline() is also difficult.





 /*
  Utility to replaces tabs in text files with spaces.
  Can either do a blind replace or replace with user-specifed tab stops
  By Malcolm McLean, 2009
    • /
  1. include <stdio.h>
  2. include <stdlib.h>
  3. include <string.h>
  4. include <limits.h>
  5. include <assert.h>
/* count the occurences of ch in str
    • /
size_t chcount(const char *str, int ch) { size_t answer = 0; while(*str) if(*str++ == ch) answer++; return answer; } /* is a string an integer?
    • /
int integral(char *str) { char *end; long x; if(!str) return 0; if(!*str) return 0; x = strtol(str, &end, 10); if(x > INT_MAX || x < INT_MIN) return 0; if(*end) return 0; return 1; } /* check that an array of integers is ascending...
Comments: 0 Tags: C, C++, Security, Tabs, detab, buffer overruns

 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.