Created
April 15, 2013 07:32
-
-
Save shoter/5386370 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tagssupported