Updates from April, 2010 Toggle Comment Threads | Keyboard Shortcuts

  • webscriptz 23:41 on 16/04/2010 Permalink | Reply
    Tags: allocation, by reference, c, c programming, char, double pointers, malloc, pointer to pointer, realloc   

    C programming: dynamic keyboard allocation with pointer to pointer 

    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
    

     
  • webscriptz 00:47 on 30/08/2008 Permalink | Reply
    Tags: , , freepascal   

    A freepascal clock 

    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 …)

     
  • webscriptz 22:04 on 29/08/2008 Permalink | Reply
    Tags: Dev C, ,   

    C & FPC 

    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:

    01
    02
    #include
    03
    #include
    04
     
    05
    int main(int argc, char *argv[])
    06
    {
    07
    long hh, mm,th, tm, ts;
    08
     
    09
    printf("Reveil a quelle heure(24) minutes? \t");
    10
    scanf("%ld", &hh);
    11
    scanf("%ld", &mm);
    12
     
    13
    th= hh+24; //ceci pr une journee
    14
    tm = 60 - mm;
    15
    ts=0;
    16
    while(th>=hh)
    17
    {
    18
    if(ts>0){ts-=1; sleep(1000);}
    19
    else if(tm>0){ts=60; tm--;}
    20
    else if (th>hh){ts=60; tm=60; th--;}
    21
    else if (th=hh){if(ts>0){ts--;}}
    22
    system("cls");
    23
    printf("%ld : %ld : %ld", th, tm, ts);
    24
     
    25
    }
    26
     
    27
    system("PAUSE");
    28
    return 0;
    29
    }
    30
     
    31
    <span style="text-decoration: line-through;">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</span> <a href="http://webscriptz.be/2008/08/29/c-fpc/108#more-108&quot; class="more-link">(More ...)</a>

     
  • webscriptz 15:12 on 15/08/2008 Permalink | Reply
    Tags: ads, , google ads, , phpbb3   

    Inserting adsense in phpbb3 templates 

    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.

     
  • webscriptz 00:04 on 15/08/2008 Permalink | Reply
    Tags: , , forums, ,   

    Adsense and forums 

    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 …)

     
  • webscriptz 23:47 on 13/08/2008 Permalink | Reply
    Tags: , , , money,   

    phpbb3 adsense input 

    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

     
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel