anyway, thanks for helping!
Type: Posts; User: cprogbiginner
anyway, thanks for helping!
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
unsigned number1, number2;
char aString = "5.55";
/* ?????????????????????????????? */
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
char newString[] = "00000";
int a = 0;
a = 8;
newString[1] = a;
Thanks everyone! Here is the best place for learning! :)
I've tried it like that:
price = 4.10;
tempPrice = (int) (price * 100);
but the result are:
Price: 4.10
What if the 4 is pass to a function as 4.10? can i just multiply it 4.10 * 100 then store it as int?
After that only do something like the code provided?
Sorry that i don't really understand. Anyone can please explain it to me? Any solution to it? Thanks!
Please help! I don't understand why tempCents = 10.00, but when it cast to unsigned, it become 9? WHY? :confused:
This only happen if the price = 4.10; If i change it to 3.10, the unsigned cents...
Thanks everyone for fast reply.
Actually i use fscanf() to read data from a file eg. '234'
data in a file doesn't have any type right?
how can i validate that '234' is a unsigned type?
if...
Thanks!
I have checked out lots of sources from the internet but i cant find the exact way how to do it.
But i do found something like this:
#include <iostream>
int main()
May i know which conversion character should i use to get an double from file? %f? eg. 4.60
how about print? %.2f?
Thanks Zuk/Kurt! It works perfectly!
Oh! It rings a bell!
So i should use %[^|]| instead of %s|
am i right?
#include <stdio.h>
#include <string.h>
int main (int argc, char** argv)
{
char itemNo[5+1];
char name[25 + 1];
char itemDescription[250 + 1];
char itemType;
Cool! Thanks alot! Am trying to apply to my code. I tried it on small program, it works. Must be some other problem with my code.
At first i use | as the delimiter in the data file. It doesnt work. After i change it to comma, it works.
before: (doesn't work)
"%[^|]|%[^|]|%u|%u\n"
Cadbury|Picnic|350|2
Please help, im a beginner in c programming.
What i thought is %[^|] will accept anything before a |, but it doesnt work.
while(fscanf(sptr, "%[^|]|%[^|]|%u|%u\n", brand, name, &price,...