Jump to content

Split sscanf


Gireada

Recommended Posts

La cererea lui Legend am facut urmatorul tutoria.

In acest tutorial va voi explica cum sa facei split cu functia sscanf. Nu stiu exact cu sa va explic pentru ca si eu deabia am invatat ce face functia asta. Dar voi incerca.

Voi incepe cu un exemplu:

[pawn]new nume[MAX_PLAYER_NAME],  bani,  warn,  factiune[24];

sscanf("Gireada, 1000, 30, SA-MP ", "p<,>s[34]iis[6]", nume, bani, warn, factiune);

printf("%s, %d, %d, %s",nume, bani, warn, factiune);

[/pawn]

Ok mai exact ce face functia asta? Stocheaza in variabile valori. Cred ca exemplul de mai sus este cel mai potrivit.

sscanf("De unde trebuie sa luam valorile", "parametrii prin care ii stocam", variabilele in care le stocam);

Cred ca toti va intrebati ce este p<,>. Cu ajutorul lui delimitam valorile cum sunt Gireada, 1000, 30, SA-MP . Daca veti rula acest exemplu veti vedea ca asa se va afisa.

Pentru cei ce vor sa foloseasca aceasta functie pentru systemele de mysql veti inlociu virgula de la p<> cu | si va deveni p<|>

De exemplu: avem un tabel (Users) cu urmatoarele coloane in urmatoare ordine ID, Nume, Bani, Skin, vom folosi astfel.

[pawn]format(Query, sizeof(Query), "SELECT * FROM `Users` WHERE `Name` = '%s' ", pName(playerid));

mysql_query(1,Query);

mysql_store_result();// stocam rezultatul

mysql_fetch_row_format(Query, "|");

sscanf(Query, "p<|>is[34]ii", ID, nume, bani, skin);//stocam in variabile valorile din tablou

printf("%d, %s, %d, %d",ID, nume, bani, skin);[/pawn]

Sper ca ati inteles.

 

1859311972_BANNER-GIREADAcopy-min.thumb.png.48e5e420ae2185dce5b244965a1d2601.png

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.