Search the web
Sign In
New User? Sign Up
c-prog · C/C++ Programmer's Mailing List
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Messages 71535 - 71564 of 71564   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Show Message Summaries   (Group by Topic) Sort by Date ^  
#71535 From: "tujare_raj1" <tujare_raj1@...>
Date: Wed Nov 18, 2009 6:15 pm
Subject: function call before main
tujare_raj1
Offline Offline
Send Email Send Email
 
can we call any function before "main" function in 'C' using any compiler
without editing "start-up" file

#71536 From: andrew clarke <mail@...>
Date: Wed Nov 18, 2009 8:15 pm
Subject: Re: function call before main
zoomosis
Offline Offline
Send Email Send Email
 
On Wed 2009-11-18 18:15:49 UTC-0000, tujare_raj1 (tujare_raj1@...)
wrote:

> can we call any function before "main" function in 'C' using any
> compiler without editing "start-up" file

Not in a standard way.  Some C compilers might support something like
that though.

In C++ you can have a constructor call a function before main() is
called.

#71537 From: Vishva <vishvaya@...>
Date: Thu Nov 19, 2009 3:01 am
Subject: swscanf() question
vish_401
Offline Offline
Send Email Send Email
 
This might be very simple to most of you.

------------------------------------
TCHAR destString[10];
unsigned long destLong = 0;

// srcStr contains a string like "xxxx=2000"
ret = swscanf(srcStr, _T"%s=%lu", destString, destLong);
  ------------------------------------

but this doesn't work. I wanted to store the "2000" as an unsigned long in
destLong.
but srcStr is completely copied to destString and destLong is as it is (0).

I guess I'm doing it wrong with type specifiers. _T"%s=%lu"

Please explain how to correct it.

--
Cheers,
Vishva


[Non-text portions of this message have been removed]

#71538 From: Tyler Littlefield <tyler@...>
Date: Thu Nov 19, 2009 3:56 am
Subject: Re: function call before main
tyler@...
Send Email Send Email
 
I don't know about a "startup" file. You could always redefine the entry point
with the linker and make that call main, but why not just call the function in
the top of main?

int main(void)
{
myFunc();
return 0;
}

On Nov 18, 2009, at 11:15 AM, tujare_raj1 wrote:

> can we call any function before "main" function in 'C' using any compiler
without editing "start-up" file
>
>



[Non-text portions of this message have been removed]

#71539 From: Rick <Mowgli53@...>
Date: Thu Nov 19, 2009 6:20 am
Subject: Re: swscanf() question
thefirstrepa...
Offline Offline
Send Email Send Email
 
At 11/18/2009 10:01 PM, you wrote:
>This might be very simple to most of you.
>
>------------------------------------
>TCHAR destString[10];
>unsigned long destLong = 0;
>
>// srcStr contains a string like "xxxx=2000"
>ret = swscanf(srcStr, _T"%s=%lu", destString, destLong);
>  ------------------------------------
>
>but this doesn't work. I wanted to store the "2000" as an unsigned long in
>destLong.
>but srcStr is completely copied to destString and destLong is as it is (0).
>
>I guess I'm doing it wrong with type specifiers. _T"%s=%lu"
>
>Please explain how to correct it.
>
>--
>Cheers,
>Vishva

I don't know about the "_T" type specifier. I'd leave it off. But try
using "%4s=%lu"

~Rick

#71540 From: "johnmatthews2000" <jm5678@...>
Date: Thu Nov 19, 2009 6:51 am
Subject: Re: swscanf() question
johnmatthews...
Offline Offline
Send Email Send Email
 
--- In c-prog@yahoogroups.com, Vishva <vishvaya@...> wrote:
>
> // srcStr contains a string like "xxxx=2000"
> ret = swscanf(srcStr, _T"%s=%lu", destString, destLong);

The %s matches a sequence of non-space characters, so it includes the '='. Try
the format string:

   " %*[^=]=%u"

The "%*[^=]" matches any characters (including spaces) apart from '=', but
doesn't store it because of the '*'.

#71541 From: "johnmatthews2000" <jm5678@...>
Date: Thu Nov 19, 2009 7:09 am
Subject: Re: swscanf() question
johnmatthews...
Offline Offline
Send Email Send Email
 
--- In c-prog@yahoogroups.com, "johnmatthews2000" <jm5678@...> wrote:
>
> The "%*[^=]" matches any characters (including spaces) apart from '=', but
doesn't store it because of the '*'.

...but you do want to store it, so it should be " %[^=]=%lu".

I don't know about the _T because I'm a C programmer.

#71542 From: Paul Herring <pauljherring@...>
Date: Thu Nov 19, 2009 11:40 am
Subject: Re: swscanf() question
shabble
Offline Offline
Send Email Send Email
 
On Thu, Nov 19, 2009 at 3:01 AM, Vishva <vishvaya@...> wrote:
> This might be very simple to most of you.
>
> ------------------------------------
> TCHAR destString[10];
> unsigned long destLong = 0;
>
> // srcStr contains a string like "xxxx=2000"
> ret = swscanf(srcStr, _T"%s=%lu", destString, destLong);

Previous comments about the string specifier aside...

Plain scanf() would require a pointer to a long - is destLong a long,
or a pointer to a long? If the former, you probably need something
akin to:

ret = swscanf(srcStr, _T"%s=%lu", destString, &destLong);

with the & before destLong.

--
PJH

http://shabbleland.myminicity.com/
http://www.chavgangs.com/register.php?referer=9375
http://www.kongregate.com/?referrer=Shabble

#71543 From: Vishva <vishvaya@...>
Date: Thu Nov 19, 2009 10:28 pm
Subject: Re: swscanf() question
vish_401
Offline Offline
Send Email Send Email
 
Well, I think Paul is right, destLong should be a pointer to a long
so the swscanf code should be like..

ret = swscanf(srcStr, _T"%s=%lu", destString, &destLong);



2009/11/19 Paul Herring <pauljherring@...>

>
>
> On Thu, Nov 19, 2009 at 3:01 AM, Vishva
<vishvaya@...<vishvaya%40gmail.com>>
> wrote:
> > This might be very simple to most of you.
> >
> > ------------------------------------
> > TCHAR destString[10];
> > unsigned long destLong = 0;
> >
> > // srcStr contains a string like "xxxx=2000"
> > ret = swscanf(srcStr, _T"%s=%lu", destString, destLong);
>
> Previous comments about the string specifier aside...
>
> Plain scanf() would require a pointer to a long - is destLong a long,
> or a pointer to a long? If the former, you probably need something
> akin to:
>
>
> ret = swscanf(srcStr, _T"%s=%lu", destString, &destLong);
>
> with the & before destLong.
>
> --
> PJH
>
> http://shabbleland.myminicity.com/
> http://www.chavgangs.com/register.php?referer=9375
> http://www.kongregate.com/?referrer=Shabble
>
>



--
Cheers,
Vishva


[Non-text portions of this message have been removed]

#71544 From: "johnmatthews2000" <jm5678@...>
Date: Fri Nov 20, 2009 6:26 am
Subject: Re: swscanf() question
johnmatthews...
Offline Offline
Send Email Send Email
 
--- In c-prog@yahoogroups.com, Vishva <vishvaya@...> wrote:
>
> Well, I think Paul is right, destLong should be a pointer to a long
> so the swscanf code should be like..
>
> ret = swscanf(srcStr, _T"%s=%lu", destString, &destLong);

...but the format string is incorrect as described previously, so it should be:

ret = swscanf(srcStr, _T"%[^=]=%lu", destString, &destLong);

(assuming the _T is correct)

#71545 From: "Anil" <anil_jupiter@...>
Date: Sun Nov 22, 2009 9:40 am
Subject: Work from Home opportunity
anil_jupiter
Offline Offline
Send Email Send Email
 
Work from Home opportunity...........Only for serious people .....

Ideal for Homemakers, students or people with spare time in day .....

Please complete this form

http://spreadsheets.google.com/viewform?formkey=dE5ET3l5eW5rS3RsQUdNUzF1ZGVST1E6\
MA

#71546 From: "K.P.Tunga" <p_tunga@...>
Date: Tue Nov 17, 2009 3:33 am
Subject: Re: Retrieving all the key values
kptunga1937
Offline Offline
Send Email Send Email
 
[mod-- http://tech.groups.yahoo.com/group/c-prog/links --mod PN]

Hello Vishva
Please let me know from where can I download "C" program language. I have some
basic knowledge about this which I want to continue. I was fluent up Array and
Point but  later discontinued because of lots of confusion.
I think with this forum support it is easy to clear my doubts.
tunga

--- On Tue, 11/17/09, Vishva <vishvaya@...> wrote:


From: Vishva <vishvaya@...>
Subject: [c-prog] Retrieving all the key values
To: c-prog@yahoogroups.com
Date: Tuesday, November 17, 2009, 7:19 AM


 



Dear all,

At the moment I'm developing an MFC application using Visual Studio 2005,
development language is C++.

There is an .ini file where most constant data are saved and retrieved.
I want to know how to read all the key values under a section from .ini file
at once.. if there is a way to do that..!

Can I do this using GetPrivateProfileSt ruct()..?

--
Cheers,
Vishva

[Non-text portions of this message have been removed]











[Non-text portions of this message have been removed]

#71547 From: "manishpchawda" <manishpchawda@...>
Date: Wed Nov 18, 2009 6:39 am
Subject: c code
manishpchawda
Offline Offline
Send Email Send Email
 
[mod-- This gets discussed ad-nauseum. The behaviour is undefined
since the code modifies x (and y) twice between sequence points.
<http://c-faq.com/expr/seqpoints.html> --mod PN]

Hi,

I am not able to understand the output of:

unsigned char x;
x = 300;
printf("%d",x);


int x,y;
x = 5;
y = 10;
printf("%d\t%d\t%d\t%d\t",x++,y++,++x,++y);

Regards,

Manish

#71548 From: Samudra Vishvajith Kapuruge <vishvaya@...>
Date: Mon Nov 23, 2009 1:14 am
Subject: Re: Retrieving all the key values
vish_401
Offline Offline
Send Email Send Email
 
K.P.Tunga wrote:
>
>
> [mod-- http://tech.groups.yahoo.com/group/c-prog/links
> <http://tech.groups.yahoo.com/group/c-prog/links> --mod PN]
>
> Hello Vishva
> Please let me know from where can I download "C" program language. I
> have some basic knowledge about this which I want to continue. I was
> fluent up Array and Point but  later discontinued because of lots of
> confusion.
> I think with this forum support it is easy to clear my doubts.
> tunga
>
> --- On Tue, 11/17/09, Vishva <vishvaya@...
> <mailto:vishvaya%40gmail.com>> wrote:
>
> From: Vishva <vishvaya@... <mailto:vishvaya%40gmail.com>>
> Subject: [c-prog] Retrieving all the key values
> To: c-prog@yahoogroups.com <mailto:c-prog%40yahoogroups.com>
> Date: Tuesday, November 17, 2009, 7:19 AM
>
>
>
> Dear all,
>
> At the moment I'm developing an MFC application using Visual Studio 2005,
> development language is C++.
>
> There is an .ini file where most constant data are saved and retrieved.
> I want to know how to read all the key values under a section from
> .ini file
> at once.. if there is a way to do that..!
>
> Can I do this using GetPrivateProfileSt ruct()..?
>
> --
> Cheers,
> Vishva
>
> [Non-text portions of this message have been removed]
>
> [Non-text portions of this message have been removed]
>
>

Hello Tunga,
※ first of all you should have replied to your own thread in this
matter. Because this thread (Retrieving all the key values) is not
related to your thread (I want to learn C Programming) [topic may be
wrong, this is what I remember]. But I've already deleted that thread
from my inbox. So I'll reply. [This is just to remind good practise in
using this type of mailing lists]

Could you please explain what you meant by "Download C programming
language". Do you want to download C compiler+editor or some C tutorial?

Cheers,
Vishva

#71549 From: Samudra Vishvajith Kapuruge <vishvaya@...>
Date: Mon Nov 23, 2009 1:32 am
Subject: Re: c code
vish_401
Offline Offline
Send Email Send Email
 
manishpchawda wrote:
>
> [mod-- This gets discussed ad-nauseum. The behaviour is undefined
> since the code modifies x (and y) twice between sequence points.
> <http://c-faq.com/expr/seqpoints.html
> <http://c-faq.com/expr/seqpoints.html>> --mod PN]
>
> Hi,
>
> I am not able to understand the output of:
>
> unsigned char x;
> x = 300;
> printf("%d",x);
>
> int x,y;
> x = 5;
> y = 10;
> printf("%d\t%d\t%d\t%d\t",x++,y++,++x,++y);
>
> Regards,
>
> Manish
>
>
> Reply to sender <mailto:?subject=c%20code> | Reply to group
> <mailto:c-prog@yahoogroups.com?subject=c%20code>
> Messages in this topic
>
<http://groups.yahoo.com/group/c-prog/message/71547;_ylc=X3oDMTM2cGs3ZWtmBF9TAzk\
3MzU5NzE0BGdycElkAzEwMTMxMzkEZ3Jwc3BJZAMxNzA1MDA2Nzg4BG1zZ0lkAzcxNTQ3BHNlYwNmdHI\
Ec2xrA3Z0cGMEc3RpbWUDMTI1ODkyNTU0MAR0cGNJZAM3MTU0Nw-->
> (1)
> Recent Activity:
>
>     * New Members
>      
<http://groups.yahoo.com/group/c-prog/members;_ylc=X3oDMTJmaDlsZTVrBF9TAzk3MzU5N\
zE0BGdycElkAzEwMTMxMzkEZ3Jwc3BJZAMxNzA1MDA2Nzg4BHNlYwN2dGwEc2xrA3ZtYnJzBHN0aW1lA\
zEyNTg5MjU1Mzk-?o=6>
>       27
>
> Visit Your Group
>
<http://groups.yahoo.com/group/c-prog;_ylc=X3oDMTJlN3RpNW9tBF9TAzk3MzU5NzE0BGdyc\
ElkAzEwMTMxMzkEZ3Jwc3BJZAMxNzA1MDA2Nzg4BHNlYwN2dGwEc2xrA3ZnaHAEc3RpbWUDMTI1ODkyN\
TUzOQ-->
> Start a New Topic
>
<http://groups.yahoo.com/group/c-prog/post;_ylc=X3oDMTJlMTBpajNkBF9TAzk3MzU5NzE0\
BGdycElkAzEwMTMxMzkEZ3Jwc3BJZAMxNzA1MDA2Nzg4BHNlYwNmdHIEc2xrA250cGMEc3RpbWUDMTI1\
ODkyNTU0MA-->
>
> To unsubscribe, send a blank message to
> <mailto:c-prog-unsubscribe@yahoogroups.com>.
> MARKETPLACE
>
> Parenting Zone: Your community resource for family and home
>
<http://us.ard.yahoo.com/SIG=14ktddu5k/M=493064.12016295.13793596.10835568/D=gro\
ups/S=1705006788:MKP1/Y=YAHOO/EXP=1258932740/L=/B=6IQPCkSO5.U-/J=125892554064479\
8/K=9O_XNbFvcsTP0GlQ5yQjhw/A=5898841/R=0/SIG=11kkq36go/*http://advision.webevent\
s.yahoo.com/parentingzone/>
>
> Yahoo! Groups
>
<http://groups.yahoo.com/;_ylc=X3oDMTJkNWRxODhvBF9TAzk3MzU5NzE0BGdycElkAzEwMTMxM\
zkEZ3Jwc3BJZAMxNzA1MDA2Nzg4BHNlYwNmdHIEc2xrA2dmcARzdGltZQMxMjU4OTI1NTQw>
>
> Switch to: Text-Only
>
<mailto:c-prog-traditional@yahoogroups.com?subject=Change%20Delivery%20Format:%2\
0Traditional>,
> Daily Digest
> <mailto:c-prog-digest@yahoogroups.com?subject=Email%20Delivery:%20Digest>
> • Unsubscribe
> <mailto:c-prog-unsubscribe@yahoogroups.com?subject=Unsubscribe> •
> Terms of Use <http://docs.yahoo.com/info/terms/>
> .
>
> _
> _,_._,___

What's your compiler?
gcc gives this output,

#include <stdio.h>
int main(void)
{
unsigned char x;
x = 300;
printf("%d", x);

return 0;
}

output> 44
? unsigned char gets truncated to 44 as 300 - 256 = 44

#include <stdio.h>
int main(void)
{
int x,y;
x=5;
y=10;
printf("%d\t%d\t%d\t%d\t",x++,y++,++x,++y);
return 0;
}
output>> 6 11 7 12
? x++, y++, ++x, ++y behave same here. so its just that x and y get
incremented.

Cheers,
Vishva

#71550 From: Abhijeet Rastogi <abhijeet.1989@...>
Date: Sun Nov 22, 2009 9:39 pm
Subject: Re: c code
shadyabhi
Offline Offline
Send Email Send Email
 
This is an un-defined behavior. The output depends on the compiler used.
Correct me if i am wrong...

On Wed, Nov 18, 2009 at 12:09 PM, manishpchawda
<manishpchawda@...>wrote:

>
>
> [mod-- This gets discussed ad-nauseum. The behaviour is undefined
> since the code modifies x (and y) twice between sequence points.
> <http://c-faq.com/expr/seqpoints.html> --mod PN]
>
> Hi,
>
> I am not able to understand the output of:
>
> unsigned char x;
> x = 300;
> printf("%d",x);
>
> int x,y;
> x = 5;
> y = 10;
> printf("%d\t%d\t%d\t%d\t",x++,y++,++x,++y);
>
> Regards,
>
> Manish
>
>
>



--
Abhijeet Rastogi
http://www.google.com/profiles/abhijeet.1989


[Non-text portions of this message have been removed]

#71551 From: Gleb <lindows_ua3@...>
Date: Sun Nov 22, 2009 12:05 am
Subject: Re: c code
lindows_ua3@...
Send Email Send Email
 
Hello, manishpchawda.
//------------------------------------------------------------------------------
#include <stdio.h>
#include <vcl.h>
#include <conio.h>
#pragma hdrstop // Borland 5.5 pragma
//------------------------------------------------------------------------------
#pragma argsused // Borland 5.5 pragma
//------------------------------------------------------------------------------
int main(int argc, char* argv[])
{
  unsigned char x; // max 0...FF(hex) 0..255(Dec)
  x = 300; //0x12C(hex) 2c(hex) - 44(dec) // Using unsigned int or unsigned long
  printf("------------------------\n");
  printf("x:= %d\n",x); // Printing 44

  int xc,yc;
  xc = 5;
  yc = 10;
  printf("------------------------\n");
  printf("xc:= %d\nyc:= %d\nxc:= %d\nyc:= %d\n",xc++,yc++,++xc,++yc);
  printf("------------------------\n");
  printf("xc:= %d\nyc:= %d\n",xc,yc);
  printf("------------------------\n");
  getch();
  return 0;
}
//------------------------------------------------------------------------------
//D:\r>test_29393
//x:= 44
//------------------------------------------------------------------------------\
--
//xc:= 6     <-after  function --- xc++
//yc:= 11    <-after  function --- yc++
//xc:= 6     <-before function --- ++xc
//yc:= 11    <-before function --- ++yc
//------------------------------------------------------------------------------\
--
//xc:= 7
//yc:= 12
//------------------------------------------------------------------------------\
--
//D:\r>

--
  Gleb                          mailto:lindows_ua3@...

#71552 From: "Peter Nilsson" <peternilsson42@...>
Date: Mon Nov 23, 2009 2:44 am
Subject: Re: c code
peternilsson42
Offline Offline
Send Email Send Email
 
"manishpchawda" <manishpchawda@...> wrote:
>
> [mod-- This gets discussed ad-nauseum. The behaviour is undefined
> since the code modifies x (and y) twice between sequence points.
> <http://c-faq.com/expr/seqpoints.html> --mod PN]
>
> Hi,
>
> I am not able to understand the output of:
>
> unsigned char x;
> x = 300;
> printf("%d",x);

If unsigned char has the range 0..255, then, being an unsigned
type, 300 will be converted modulo 256, thus resulting in 44
(if my maths is correct.)

> int x,y;
> x = 5;
> y = 10;
> printf("%d\t%d\t%d\t%d\t",x++,y++,++x,++y);

The behaviour of this code is undefined. As such it may not
even compile. Whatever output you get on one system is
worthless since it is not guaranteed to be reproducable
on any other system, or even the same system on a different
day.

Note: compilers are not required to work out arguments to
functions (like printf) in left to right, or right to left,
or evens first, odds seconds second, or random order. Quite
simply, the order of evaluation of arguments and their
subexpressions is unspecified. Since there is no guarantee
that x++ will be evaluated before or after ++x, the code
modifies x twice between two sequence points. The C
language does not guarantee a behaviour (let alone a value)
when that happens.

--
Peter

#71553 From: Abhijeet Rastogi <abhijeet.1989@...>
Date: Mon Nov 23, 2009 1:19 am
Subject: Re: Retrieving all the key values
shadyabhi
Offline Offline
Send Email Send Email
 
You download a Language. To learn C you download a Compiler. Download GCC.
Just fo a google search and you will get the link to download. To learn the
language, just search for online tutorials on google. Also, you can download
a book on C by "Deitel & Deitel". I have read the book and its quite nice,,,

On Mon, Nov 23, 2009 at 6:44 AM, Samudra Vishvajith Kapuruge <
vishvaya@...> wrote:

>
>
> K.P.Tunga wrote:
> >
> >
> > [mod-- http://tech.groups.yahoo.com/group/c-prog/links
> > <http://tech.groups.yahoo.com/group/c-prog/links> --mod PN]
> >
> > Hello Vishva
> > Please let me know from where can I download "C" program language. I
> > have some basic knowledge about this which I want to continue. I was
> > fluent up Array and Point but later discontinued because of lots of
> > confusion.
> > I think with this forum support it is easy to clear my doubts.
> > tunga
> >
> > --- On Tue, 11/17/09, Vishva <vishvaya@... <vishvaya%40gmail.com>
> > <mailto:vishvaya%40gmail.com <vishvaya%2540gmail.com>>> wrote:
> >
> > From: Vishva <vishvaya@... <vishvaya%40gmail.com> <mailto:
> vishvaya%40gmail.com <vishvaya%2540gmail.com>>>
>
> > Subject: [c-prog] Retrieving all the key values
> > To: c-prog@yahoogroups.com <c-prog%40yahoogroups.com> <mailto:
> c-prog%40yahoogroups.com <c-prog%2540yahoogroups.com>>
>
> > Date: Tuesday, November 17, 2009, 7:19 AM
> >
> >
> >
> > Dear all,
> >
> > At the moment I'm developing an MFC application using Visual Studio 2005,
> > development language is C++.
> >
> > There is an .ini file where most constant data are saved and retrieved.
> > I want to know how to read all the key values under a section from
> > .ini file
> > at once.. if there is a way to do that..!
> >
> > Can I do this using GetPrivateProfileSt ruct()..?
> >
> > --
> > Cheers,
> > Vishva
> >
> > [Non-text portions of this message have been removed]
> >
> > [Non-text portions of this message have been removed]
> >
> >
>
> Hello Tunga,
> ※ first of all you should have replied to your own thread in this
> matter. Because this thread (Retrieving all the key values) is not
> related to your thread (I want to learn C Programming) [topic may be
> wrong, this is what I remember]. But I've already deleted that thread
> from my inbox. So I'll reply. [This is just to remind good practise in
> using this type of mailing lists]
>
> Could you please explain what you meant by "Download C programming
> language". Do you want to download C compiler+editor or some C tutorial?
>
> Cheers,
> Vishva
>
>
>



--
Abhijeet Rastogi
http://www.google.com/profiles/abhijeet.1989


[Non-text portions of this message have been removed]

#71554 From: Thomas Hruska <thruska@...>
Date: Mon Nov 23, 2009 2:45 pm
Subject: Re: Re: Retrieving all the key values
shininglightpro
Offline Offline
Send Email Send Email
 
John Gaughan wrote:
> Paul Herring wrote:
>> It means application specific data like this should be stored in the
>> registry, not in INI files, and you should really be using the
>> registry version of those functions for new programs.
>>
>
> I never did like the registry. I would store data in flat files in the
> user's profile, in a platform-independent way. XML is good for this,
> although verbose.
>
> My personal philosophy is that if a user cannot use a text editor to
> edit a program's configuration, or cannot easily copy a configuration
> file to another machine, the configuration is not portable enough. While
> registry entries are exportable and importable, it is a pain to do and
> most users (even experienced ones) would be lost.

IMO, JSON is far better than XML.  Google has long since moved away from
XML as their primary data exchange format.

What really needs to happen is every programmer needs to agree on a
consistent way to easily migrate application data from all applications.
   That way a user can simply up and move their application data between
computers.

--
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* MyTaskFocus 1.1
Get on task.  Stay on task.

http://www.CubicleSoft.com/MyTaskFocus/

#71555 From: Thomas Hruska <thruska@...>
Date: Mon Nov 23, 2009 2:49 pm
Subject: Re: Re: swscanf() question
shininglightpro
Offline Offline
Send Email Send Email
 
johnmatthews2000 wrote:
> --- In c-prog@yahoogroups.com, Vishva <vishvaya@...> wrote:
>> Well, I think Paul is right, destLong should be a pointer to a long
>> so the swscanf code should be like..
>>
>> ret = swscanf(srcStr, _T"%s=%lu", destString, &destLong);
>
> ...but the format string is incorrect as described previously, so it should
be:
>
> ret = swscanf(srcStr, _T"%[^=]=%lu", destString, &destLong);
>
> (assuming the _T is correct)

_T("%[^=]=%lu")

_T is a macro that appends a 'L' modifier to the string if compiling for
Unicode.  Otherwise, it evaluates to itself.

--
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* MyTaskFocus 1.1
Get on task.  Stay on task.

http://www.CubicleSoft.com/MyTaskFocus/

#71556 From: "johnmatthews2000" <jm5678@...>
Date: Mon Nov 23, 2009 8:11 pm
Subject: Re: swscanf() question
johnmatthews...
Offline Offline
Send Email Send Email
 
--- In c-prog@yahoogroups.com, Thomas Hruska <thruska@...> wrote:
>
> _T is a macro that appends a 'L' modifier to the string if
> compiling for Unicode. Otherwise, it evaluates to itself.

Thanks Thomas.

#71557 From: John Gaughan <john@...>
Date: Tue Nov 24, 2009 1:49 am
Subject: Re: Re: Retrieving all the key values
john23874
Offline Offline
Send Email Send Email
 
Thomas Hruska wrote:
> IMO, JSON is far better than XML.  Google has long since moved away from
> XML as their primary data exchange format.
>

I have heard of JSON before but never really looked at it closely. I
will take another look. The web site takes an interesting approach of
describing the grammar using simple pictures, and I was able to
understand its structure in about 5 seconds.

> What really needs to happen is every programmer needs to agree on a
> consistent way to easily migrate application data from all applications.
>   That way a user can simply up and move their application data between
> computers.
>

This is why I mentioned using XML (or another open interchange format)
in the user's profile. Whether using Unix or Windows, the idea of a
"profile" is well-defined. Burying stuff in the registry or with the
program data just makes things more difficult.

If all programs used this method it would be easy to transfer
applications. A lot of software does: however, I have found that more
than just user settings, a lot of programs store core data in the
registry. This is ok for some applications: some can run regardless of
what is in the registry, and some will repair its contents automatically
or manually but easily (e.g. 7-zip will repair file associations if you
tell it to).

Personally, I am in favor of applications that do not touch the registry
at all. Eclipse, my IDE of choice, is completely self-contained in its
little sandbox of a directory. There are no user settings: workspaces
contain this metadata, and are easily migrated.

--
John Gaughan
http://www.jtgprogramming.org/

#71558 From: "johnmatthews2000" <jm5678@...>
Date: Wed Nov 25, 2009 2:48 pm
Subject: fgets() behaviour after EOF
johnmatthews...
Offline Offline
Send Email Send Email
 
If fgets() on a FILE* returns 0 indicating end-of-file, is it safe to call it
again? That is, is it guaranteed that the function will return 0 again with no
undesirable side effects?

This is in C, if it makes a difference.

#71559 From: Paul Herring <pauljherring@...>
Date: Wed Nov 25, 2009 3:23 pm
Subject: Re: fgets() behaviour after EOF
shabble
Offline Offline
Send Email Send Email
 
On Wed, Nov 25, 2009 at 2:48 PM, johnmatthews2000 <jm5678@...> wrote:
> If fgets() on a FILE* returns 0 indicating end-of-file,

fgets() returns on EOF, *or* an error (someone just unplugged that USB
pen you were reading. I used to use the example of someone removing
the floppy disk, but that seems a bit old hat now.)

> is it safe to call it again? That is, is it guaranteed that the function
> will return 0 again with no undesirable side effects?

I'd say no. Because it might not be EOF. You distinguish between the
two using feof() and ferror(). And if you're going to that trouble,
you might as well ensure there isn't a second attempt to read.

The Standard (from my quick skim) is silent on what the behaviour
should/may/must be on a second call on a stream that has already
returned one error.

> This is in C, if it makes a difference.

I think we need a bit more background to the reason for the question ;)

--
PJH

http://shabbleland.myminicity.com/
http://www.chavgangs.com/register.php?referer=9375
http://www.kongregate.com/?referrer=Shabble

#71560 From: "johnmatthews2000" <jm5678@...>
Date: Wed Nov 25, 2009 3:50 pm
Subject: Re: fgets() behaviour after EOF
johnmatthews...
Offline Offline
Send Email Send Email
 
--- In c-prog@yahoogroups.com, Paul Herring <pauljherring@...> wrote:
>
> I'd say no.

Thanks Paul.

> I think we need a bit more background to the reason for the question ;)

Log data has been collected in a big circular buffer and dumped to file. The
circular buffer is implemented using a bank of SDRAM with a wrapping index
pointing to the 'end' of the buffer.

However the data is dumped from low SDRAM address to high, without the index
value. But the data is timestamped, so I can determine where the 'end' of the
buffer is by looking for a discontinuity in the timestamps.

My algorithm is:

1. count the number of records N up to the timestamp discontinuity
2. process the remaining records up to the end of file
3. rewind the file back to the beginning
4. process N records (which were just counted in step 1)

This should result in all the records being processed in timestamp order.

But if the circular buffer index is 0 ie. there is no timestamp discontinuity in
the file, then step 1 will result in reaching the end of file with N equaling
the number of records in the file. So moving on to step 2, we are already at the
end of file when we attempt to read the next record, hence my question.

It's not difficult to avoid this situation, but I wanted to keep the algorithm
as simple as possible.

Hope that makes sense.

#71561 From: andrew clarke <mail@...>
Date: Wed Nov 25, 2009 3:54 pm
Subject: Re: fgets() behaviour after EOF
zoomosis
Offline Offline
Send Email Send Email
 
On Wed 2009-11-25 14:48:42 UTC-0000, johnmatthews2000 (jm5678@...) wrote:

> If fgets() on a FILE* returns 0 indicating end-of-file, is it safe to
> call it again? That is, is it guaranteed that the function will return
> 0 again with no undesirable side effects?

fgets() returns a pointer, not an integer.

What are you trying to achieve?

Normally you'd do something like:

   #define BUFSIZE 512
   char s[BUFSIZE], *p;

   p = fgets(s, sizeof s, fp);

   while (p != NULL)
   {
       print("%s", p);
       p = fgets(s, sizeof s, fp);
   }

   if (ferror(fp))
   {
       /* something bad happened! */

       /* ... */
   }

#71562 From: "johnmatthews2000" <jm5678@...>
Date: Wed Nov 25, 2009 7:27 pm
Subject: Re: fgets() behaviour after EOF
johnmatthews...
Offline Offline
Send Email Send Email
 
--- In c-prog@yahoogroups.com, andrew clarke <mail@...> wrote:
>
> On Wed 2009-11-25 14:48:42 UTC-0000, johnmatthews2000 (jm5678@...) wrote:
>
> fgets() returns a pointer, not an integer.

0 in a pointer context is the null pointer, which is what I meant - I should
have made that clear.

> Normally you'd do something like:
>
>   p = fgets(s, sizeof s, fp);
>
>   while (p != NULL)
>   {
>       print("%s", p);
>       p = fgets(s, sizeof s, fp);
>   }

Well, something like it I suppose :-)

   while (fgets(s, sizeof s, fp))
   {
       printf("%s", s);
   }
   :

#71563 From: "Peter Nilsson" <peternilsson42@...>
Date: Wed Nov 25, 2009 10:11 pm
Subject: Re: fgets() behaviour after EOF
peternilsson42
Offline Offline
Send Email Send Email
 
--- In c-prog@yahoogroups.com, "johnmatthews2000" <jm5678@...> wrote:
> If fgets() on a FILE* returns [null] indicating end-of-file,
> is it safe to call it again?

Yes.

> That is, is it guaranteed that the function will return [null]
> again

No.

> with no undesirable side effects?

All standard input functions are based on fgetc. Under C99,
end of file is 'sticky', under C89 it's unspecified. Either way,
you should call clearerr() before attempting to read again.

--
Peter

#71564 From: "johnmatthews2000" <jm5678@...>
Date: Wed Nov 25, 2009 10:23 pm
Subject: Re: fgets() behaviour after EOF
johnmatthews...
Offline Offline
Send Email Send Email
 
--- In c-prog@yahoogroups.com, "Peter Nilsson" <peternilsson42@...> wrote:
>
> All standard input functions are based on fgetc. Under C99,
> end of file is 'sticky', under C89 it's unspecified. Either way,
> you should call clearerr() before attempting to read again.

Thanks Peter.

Messages 71535 - 71564 of 71564   Oldest  |  < Older  |  Newer >  |  Newest
Advanced
Add to My Yahoo!      XML What's This?

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help