Skip to content

Instantly share code, notes, and snippets.

@shoter
Created April 15, 2013 07:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shoter/5386370 to your computer and use it in GitHub Desktop.
Save shoter/5386370 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <iostream>
#include <conio.h>
#include <stdlib.h>
//napisz program ktory tablice 8 elementowa, z uzykotniwkami.
//nastepnie liczbe
char buffer[10000];
void *wsk = (void *)buffer;
void* wczytaj_liczbe()
{
void *zwrocenie = malloc(4);
void *wielkosc = malloc(4);
*( (int*) zwrocenie) = 0;
*( (int *) wielkosc) = 1;
char liczbaBuffer[10];
void *wskL = (void *)liczbaBuffer;
buffer[ fread(buffer,1,sizeof(buffer),stdin) ] = 0;
while( (*((char*)wsk)) == '\n' || (*((char*)wsk)) == '\t' || (*((char*)wsk)) == ' ' )
wsk = (void*) ( ( (char *) wsk) + 1);
while( *((char*)wsk) != 0 && *((char*)wsk) != '\n' )
{
*( (char*) wskL) = *( (char*) wsk);
wskL =(void *)( ( (char*) wskL) + 1);
// wskL = ( (void *) ( (char *) (*( (char*) wskL) = *( (char*) wsk)) + 1));
wsk = (void*) ( ( (char *) wsk) + 1 );
}
do
{
wskL = (void *)( ( (char*) wskL) - 1);
*((int*) zwrocenie) += (int) ( (*( (char*) wskL) ) - '0') * (*( (int*)wielkosc));
std::cout << *( (char*) wskL) << " - " << *((int*)wielkosc) << " - " << (int) ( (*( (char*) wskL) ) - '0') << std::endl;
*( (int*)wielkosc) *= 10;
}while ( ( (char*) wskL) != liczbaBuffer);
*((int*) ( ( (char *) wskL) + 1 )) = 0;
delete wielkosc;
return zwrocenie;
}
int main()
{
void *liczba = wczytaj_liczbe();
std::cout << "liczba to : " << *( (int*) liczba) << std::endl;
getch();
delete wsk;
}
@shoter
Copy link
Author

shoter commented Apr 15, 2013

  • @mentions, #refs, links, formatting, and tags supported
  • list syntax required (any unordered or ordered list supported)
  • this is a complete item
  • this is an incomplete item

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment