Ga naar inhoud

C++ vraagjes


anoniem

Aanbevolen berichten

1) Geen idee 2) [code:1:a524badef8]#include <stdio.h> // a function taking no arguments and returning nothing // this function prints the famous string 'Hello world' void abc() { printf("Hello world\n"); } // another function returning a pointer to a char and taking an argument // this function multiplies the argument by 2 and // converts the result to a string char *def(int i) { static char buf[10]; sprintf(buf,"%d",2*i); return buf; } int main() { // pointers to function declaration void (*myfunc1)(); char *(*myfunc2)(int i); // other variables declaration char *ptr; // assign the functions myfunc1=abc; myfunc2=def; // call the functions myfunc1(); ptr=myfunc2(5); printf("%s\n", ptr); } [/code:1:a524badef8] De eerste twee regels in main beantwoorden je vraag, de overige laten zien hoe je vervolgens toekent en gebruikt. Overigens heeft dit niks met C++ te maken, maar met C. PS: De voorbeeld-code is geschreven in C en niet in C++.
Link naar reactie

Om een reactie te plaatsen, moet je eerst inloggen

Gast
Reageer op dit topic

×   Geplakt als verrijkte tekst.   Herstel opmaak

  Er zijn maximaal 75 emoji toegestaan.

×   Je link werd automatisch ingevoegd.   Tonen als normale link

×   Je vorige inhoud werd hersteld.   Leeg de tekstverwerker

×   Je kunt afbeeldingen niet direct plakken. Upload of voeg afbeeldingen vanaf een URL in

  • Populaire leden

    Er is nog niemand die deze week reputatie heeft ontvangen.

  • Leden

    Geen leden om te tonen

×
×
  • Nieuwe aanmaken...