News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

C compiler conventions

Started by Adamanteus, February 17, 2008, 02:29:38 PM

Previous topic - Next topic

Adamanteus

 Attached file that's giving wrong warnings and not compiling if uncomment last line !
Small remark about povars32.bat - last line is better : if not "%1." == "." cd %1

JohnF

#1
I've corrected a few things and made it more readable (IMO), see if this code will satisfy.


#include "stdio.h"
#include "windows.h"

size_t memavail(void)
{
return GetFreeSpace(0);
}

typedef unsigned long grant;

char gucmp(const grant * number1, const grant * number2)
{
if (number1[1] > number2[1])
return 1;
else if (number1[1] < number2[1])
return -1;
else if ((number1[0]) > (number2[0]))
return 1;
else if ((number1[0]) < (number2[0]))
return -1;
else
return 0;
}

char *stristalk(const char *string, const char sim)
{
unsigned char *substr = (unsigned char *)(string + strlen(string));
while ((void *)substr != (void *)string)
{ // BUG !
substr--;
if (*substr > (unsigned char)sim)
return (char *)substr;
};
return NULL;
}

char *test = "y bug\t!";

int main(void)
{
grant x[2] = { 1, 1 }, y[2] = { 2, 2 };
puts(stristalk(test, 'x'));
while (gucmp(x, y) > 0){}
return 0;
}


John