Archive for the ‘source code’ Category

C programming: dynamic keyboard allocation with pointer to pointer

Friday, April 16th, 2010 |

Something I’ve written for a project I have to do for school, it’s without bugs at least on visual studio 2008.

The little story about this code:

This is a dynamic memory allocation function for text entered by the user.

You give the addresses from pointers to memory placements to the function, it only return errors by value, everything else is returned by reference (pointer to pointer).

**string is the string pointer
**cntrChar is a counter for the number for characters

**cntrChar is used in another function to verify that the chain of characters entered, is longer then 1 because ‘\n’ is also seen as character so you need more then 1 to pass that test normally but it depends on the requirements of the program created.


int keyboardInputString(char **string, int **cntrChar){

	char c, *iString;

	int i=0;

	iString = (char*)malloc(sizeof(char));

	if(iString != NULL){

		do{

			c = getchar();

			*(iString+i)=c;

			i++;

			iString = (char*) realloc (iString, (i+1) * sizeof(char));

			if(iString == NULL)

				return 1;

		}while(c != '\n');

		*(iString+i-1)='\0';

		*string = iString;

		*cntrChar = &i;

		return 0;

	}

	else{

		return 1;

	}

}

exemple:

   if(strcmp(**string, "exit") && **cntrChar >1)
     //your code here

A freepascal clock

Saturday, August 30th, 2008 |

A basical console clock written in freepascal by me, even if it’s an old language, I have to practice on it for school.

Here you got the code, I’ve added little comments but it isn’t a lot. hh = hour mm = minutes ss= seconds

(more…)

C & FPC

Friday, August 29th, 2008 |

C programming and pascal, that’s what I’m doing for the moment, I have an exam in 5 days, man I hate it.

Just finished a clock in C: you give the time for tomorrow and he’ll count it down. But it’s basic:

#include
#include

int main(int argc, char *argv[])
{
long hh, mm,th, tm, ts;

printf(“Reveil a quelle heure(24) minutes? \t”);
scanf(“%ld”, &hh);
scanf(“%ld”, &mm);

th= hh+24; //ceci pr une journee
tm = 60 – mm;
ts=0;
while(th>=hh)
{
if(ts>0){ts-=1; sleep(1000);}
else if(tm>0){ts=60; tm–;}
else if (th>hh){ts=60; tm=60; th–;}
else if (th=hh){if(ts>0){ts–;}}
system(“cls”);
printf(“%ld : %ld : %ld”, th, tm, ts);

}

system(“PAUSE”);
return 0;
}

I’m more or less pleased but still the infinite refreshments aren’t what I wanted and sorry about the comment but in exercises I don’t use them (more…)

Inserting adsense in phpbb3 templates

Friday, August 15th, 2008 |

I have to review some things from my last post about phpbb3 adsense. Infact it doesn’t matter where you put it just don’t do it in the if statements of the templates because you won’t be able to see it always.

Adsense and forums

Friday, August 15th, 2008 |

Where do you put AdSense when you manage a forum? It’s the question I’m thinking about for some days now. I’m trying different approaches every once in a while until I’m satisfied.

Just before you we get started, note that forums.webscriptz.be isn’t getting a lot of visitors, this is basically because I have to deal with big competitors in the same niche of the web. Also because I’m not promoting the place because, well I’m short of time and I don’t want to spend money on something that I can earn myself by doing the work AdSense does.

I’ve got my little theories on where to put AdSense on my blog, I don’t have the very best of designs for phpbb3 but I’m thinking positive.

(more…)

phpbb3 adsense input

Wednesday, August 13th, 2008 |

I’ve solved the problems with adsense in the template files, the page I found truly explained a lot, apparently I’ve inputted the script into the wrong lines of code, odd as it seems.

To the website

About Me

Here I'll share my knowledge, discovery and experience related to my hobby and work. Most articles on this site are related to blog design, short reviews, tips and make money online. More

Find entries :