473,326 Members | 2,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

sscanf error

bool variant_t::Convert( fieldtype_t newType )
{
if ( newType == fieldType )
{
return true;
}

//
// Converting to a null value is easy.
//
if ( newType == FIELD_VOID )
{
Set( FIELD_VOID, NULL );
return true;
}

//
// FIELD_INPUT accepts the variant type directly.
//
if ( newType == FIELD_INPUT )
{
return true;
}

switch ( fieldType )
{
case FIELD_INTEGER:
{
switch ( newType )
{
case FIELD_FLOAT:
{
SetFloat( (float) iVal );
return true;
}

case FIELD_BOOLEAN:
{
SetBool( iVal != 0 );
return true;
}
}
break;
}

case FIELD_FLOAT:
{
switch ( newType )
{
case FIELD_INTEGER:
{
SetInt( (int) flVal );
return true;
}

case FIELD_BOOLEAN:
{
SetBool( flVal != 0 );
return true;
}
}
break;
}

//
// Everyone must convert from FIELD_STRING if possible, since
// parameter overrides are always passed as strings.
//
case FIELD_STRING:
{
switch ( newType )
{
case FIELD_INTEGER:
{
if (iszVal != NULL_STRING)
{
SetInt(atoi(STRING(iszVal)));
}
else
{
SetInt(0);
}
return true;
}

case FIELD_FLOAT:
{
if (iszVal != NULL_STRING)
{
SetFloat(atof(STRING(iszVal)));
}
else
{
SetFloat(0);
}
return true;
}

case FIELD_BOOLEAN:
{
if (iszVal != NULL_STRING)
{
SetBool( atoi(STRING(iszVal)) != 0 );
}
else
{
SetBool(false);
}
return true;
}

case FIELD_VECTOR:
{
Vector tmpVec = vec3_origin;
if (sscanf(STRING(iszVal), "[%f %f %f]", &tmpVec[0], &tmpVec[1],
&tmpVec[2]) == 0)
{
// Try sucking out 3 floats with no []s
sscanf(STRING(iszVal), "%f %f %f", &tmpVec[0], &tmpVec[1],
&tmpVec[2]);
}
SetVector3D( tmpVec );
return true;
}

case FIELD_COLOR32:
{
int nRed = 0;
int nGreen = 0;
int nBlue = 0;
int nAlpha = 255;

problem-> sscanf(STRING(iszVal), "%d %d %d %d", &nRed, &nGreen, &nBlue,
&nAlpha);
SetColor32( nRed, nGreen, nBlue, nAlpha );
return true;
}

case FIELD_EHANDLE:
{
// convert the string to an entity by locating it by classname
CBaseEntity *ent = NULL;
if ( iszVal != NULL_STRING )
{
// FIXME: do we need to pass an activator in here?
ent = gEntList.FindEntityByName( NULL, iszVal, NULL );
}
SetEntity( ent );
return true;
}
}

break;
}

case FIELD_EHANDLE:
{
switch ( newType )
{
case FIELD_STRING:
{
// take the entities targetname as the string
string_t iszStr = NULL_STRING;
if ( eVal != NULL )
{
SetString( eVal->GetEntityName() );
}
return true;
}
}
break;
}
}

// invalid conversion
return false;
}
Can anyone tell me a good reason why i might be getting a sscanf
identifier not found error other than stdio.h missing

- it doesnt appear to be a syntax error
-

May 25 '06 #1
9 2961
GrispernMix wrote:
[...]
Can anyone tell me a good reason why i might be getting a sscanf
identifier not found error other than stdio.h missing
No. Do you actually have 'stdio.h' included?
- it doesnt appear to be a syntax error


No, it does not.

Preserve your file (back it up somewhere), remove everything from
that function except the line that gives you the error and some other
stuff for it to work, and then drop all other includes and functions
from that file (IOW, distill it to this line only). Then see if it
compiles. Make sure you only include the headers you need.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
May 25 '06 #2
could it be problem with my compiler microsoft visual 2005, i have
another sscanf problem which i hope can show me why i keep getting the
identifer not found

#include <stdio.h>
#include <wchar.h>
#include <conio.h>

int main( void )
{
char tokenstring[] = "15 12 14...";
char s[81];
char c;
int i;
float fp;

// Input various data from tokenstring:
// max 80 character string:
sscanf( tokenstring, "%80s", s ); // C4996
sscanf( tokenstring, "%c", &c ); // C4996
sscanf( tokenstring, "%d", &i ); // C4996
sscanf( tokenstring, "%f", &fp ); // C4996
// Note: sscanf is deprecated; consider using sscanf_s instead

// Output the data read
printf( "String = %s\n", s );
printf( "Character = %c\n", c );
printf( "Integer: = %d\n", i );
printf( "Real: = %f\n", fp );
getch();

}

May 25 '06 #3
this program is not working either

May 25 '06 #4
IT WAS THE DEPRECIATION!!!!!! pardon my loudness, but the sscanf was
fixed with a mere sscanf_s

May 25 '06 #5
nm it didnt work

May 25 '06 #6
GrispernMix wrote:
could it be problem with my compiler microsoft visual 2005, i have
another sscanf problem which i hope can show me why i keep getting the
identifer not found

#include <stdio.h>
#include <wchar.h>
#include <conio.h>
This is non-standard.

int main( void )
{
char tokenstring[] = "15 12 14...";
char s[81];
char c;
int i;
float fp;

// Input various data from tokenstring:
// max 80 character string:
sscanf( tokenstring, "%80s", s ); // C4996
[...]
}


If I remove 'getch', it compiles fine here. There must be something
in your project settings. If you need to find a solution specific
for VC++ v8, post to 'microsoft.public.vc.language' where you can name
the compiler settings (off-topic here). I bet folks there can help.

<OT>
VC++ v8 does report 'sscanf' as "deprecated" (for whatever reason),
but compiles nonetheless. Could it be you have all warnings treated
as errors? Add [#pragma warning] to ignore it.
</OT>

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
May 25 '06 #7
GrispernMix wrote:
nm it didnt work

You just three messages that make no sense, as you didn't provide any
context. See the information below.

Brian

--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
May 25 '06 #8
Default User wrote:
You just three messages that make no sense, [..]


Aha, yes, m-hm..
May 26 '06 #9
Victor Bazarov wrote:
Default User wrote:
You just three messages that make no sense, [..]


Aha, yes, m-hm..


Such is life.

Brian
May 26 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: ishekara | last post by:
Hi, As per the msdn knowledge base.. i find the following "In an application developed with Microsoft C or C/C++, the sscanf() function is a good alternative to the atof() function to convert...
3
by: whisper | last post by:
Hello: I am trying to write code to read in a bunch of lines from stdin, each containing a (variable) number of integers and writing each integer in a separate line to stdout. I came up the...
4
by: smshahriar | last post by:
Hi, I want to scan from the following string all the hex numbers and populate an array of integers: 0x27 0x00 0x30 0x00 0x33 0x00 0x36 0x00
6
by: ATS | last post by:
INF: Has anyone made a CString, sprintf, and sscanf for .NET? Please help, I want to code with PURE .NET (i.e. pure CLR). No MFC, No ATL, no C-Run Time Library. But I want CString, sprintf,...
17
by: Yogi_Bear_79 | last post by:
I have the following code: sscanf(line, "%d", n_ptr) !=1 || n_ptr <=0; It only partially works. If the user types a character other than 0-9 to start the string it fails. However as long as...
1
by: ziroi | last post by:
Hello! I am new here to the forums and still learning C. I understand your policies on coursework, but I have an error that I've run around and around and can't figure out where my problem is...
7
by: gio | last post by:
suppose I have: .... char str1; char str2; int ret; fgets(str1, LEN, stdin); //str1 can contain just '\n' and '\0' ret=sscanf(str1, "%s", str2); ....
24
by: allpervasive | last post by:
hi all, this is reddy, a beginner to c lang,,here i have some problems in reading and modifying the contents of a file,, hope you can help to solve this problem. Here i attach the file to be...
5
by: a | last post by:
After reading FAQ comp.lang.c section 12 and googling again, still there is no threads talking about reading a series of numbers. The input files, somehow structured, is exemplified below: ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.