C parameter question

Ok, so I am currently in the process in writing a C library for a small kernel I am making for fun, and my question is:
Is it possible to have a function specify only one parameter in the code and have any extra parameters put into an array, let's call it extra[].
Here is the code I have:
unsigned int k_printf(char *message)
char *vidmem = (char *) 0xb8000;
unsigned int i = 0;
i = (line*80*2);
while(*message != 0) {
if(*message=='\n') {
line++;
i = (line*80*2);
*message++;
else if(*message=='%s') {
else {
vidmem[i] = *message;
*message++;
i++;
vidmemcount++;
vidmem[i] = WHITE_TXT;
i++;
vidmemcount++;
line++;
return 1;
I am currently trying to make a close but less powerful printf() equivalent. For example:
printf("My name is %s and my friends name is %s", myname, friendsname);
I want to be able to make an extra[] array that stores myname and friendsname in extra[0] and extra[1]. Is this possible?

ewaller wrote:
itsbrad212 wrote:
Ok, so I am currently in the process in writing a C library for a small kernel I am making for fun, and my question is:
Is it possible to have a function specify only one parameter in the code and have any extra parameters put into an array, let's call it extra[].
Here is the code I have:
unsigned int k_printf(char *message)
char *vidmem = (char *) 0xb8000;
unsigned int i = 0;
i = (line*80*2);
while(*message != 0) {
if(*message=='\n') {
line++;
i = (line*80*2);
*message++;
else if(*message=='%s') {
else {
vidmem[i] = *message;
*message++;
i++;
vidmemcount++;
vidmem[i] = WHITE_TXT;
i++;
vidmemcount++;
line++;
return 1;
I am currently trying to make a close but less powerful printf() equivalent. For example:
printf("My name is %s and my friends name is %s", myname, friendsname);
I want to be able to make an extra[] array that stores myname and friendsname in extra[0] and extra[1]. Is this possible?
Okay, here goes:
where is line defined, allocated, initialized?
where is vidmemcount defined, allocated, initialized?  what is it used for?
Avoid *80*2.  Especially in multiple places.  Use a #define in case you change the size latter. 
Even better, how about creating records on the heap using malloc and then keeping an array of references to the records.[Edit :: Never mind -- I see what you are up to.  Ignore this]
Rather than :
while(*message != 0) {
if(*message=='\n') {
line++;
i = (line*80*2);
*message++;
else if(*message=='%s') {
else {
vidmem[i] = *message;
*message++;
i++;
vidmemcount++;
vidmem[i] = WHITE_TXT;
i++;
vidmemcount++;
How about :
char* vm = vidmem;
while ( *message)
if ((*message)=='\n')
vm=vidmem+SPAN * (++line);
message++;
else
*(vm++)=*(message++);
*(vm++)=WHITE_TXT;
edit : fixed bug in my code
Thanks for the tips! Any speed improvement whatsoever is crucial when doing things like this.
Here are those defined at the beginning of the functions.h file:
unsigned int line = 0;
char *vidmem = (char *) 0xb8000;
unsigned int vidmemcount = 0;

Similar Messages

  • Type parameter question

    I'm trying to figure out if I can simplify this interface definition:
    public interface BaseService<T extends BaseEntity<ID>, ID> {
        public T find(ID id);
        public void persist(T entity);
    }To implement this interface, I have to do something like:
    public class CountryService implements BaseService<Country, Long> {}Where Country is defined like:
    public class Country extends BaseEntity<Long> {}My question is: Is there some way to get rid of the second type parameter in BaseService, so that I can do this instead:
    public class CountryService implements BaseService<Country> {}but still enforce the type of the id parameter on the find() method in BaseService?
    The obvious solution doesn't compile:
    {color:#ff0000}public interface BaseService<T extends BaseEntity<ID>> {
       public T find(ID id);
       public void persist(T entity);
    }{color}
    Any help is greatly appreciated!

    Hi,
    Another suggestion is to parametrize BaseEntity on a ID hierarchy
    public abstract class BaseEntity<T extends ID> {
        public abstract T getId();
    }This can lead to the following the BaseService:
    public interface BaseService<T extends BaseEntity<? extends ID>> {
        T find(ID id);
        void persist(T entity);
    }Now if you define Country as
    public class Country extends BaseEntity<ID> {
        @Override
        public ID getId() {
            return null;
    }and finally CountryService as
    public class CountryService implements BaseService<Country> {
        @Override
        public Country find(ID id) {
            return null;
        @Override
        public void persist(Country entity) {
    }Hope this help.

  • Generics parameter question

    I'm trying to create a binary tree that implements Map, or extends AbstractMap.package binarytree;
    import java.util.Collection;
    import java.util.Map;
    import java.util.Set;
    import java.util.Map.Entry;
    public abstract class MapTest<K, D> implements Map<K, D> {
         public Set<Entry<K, D>> entrySet() {
              // TODO Auto-generated method stub
              return null;
         public void putAll(Map<? extends K, ? extends D> m) {
              Set<Entry<? extends K, ? extends D>> s = m.entrySet();
              // Error on the above line.
                    //Type mismatch: cannot convert from Set<Map.Entry<capture#1-of ? extends K,capture#2-of ? extends D>> to Set<Map.Entry<? extends K,? extends D>>     
    }I'm using Eclipse. It wants me to change the line to :
    Set<?> s = m.entrySet();I don't understand. EntrySet() is supposed to return Set<Entry<K, D>>, where K, D are the type parameters of the Map. The type of my Map parameter, m, is Map<? extends K, ? extends D>. Shouldn't m.entrySet() return Set<Entry<? extends K, ? extends D>>?
    Why is does Eclipse want me to define the return value as a Set<?>?

    Let me try an answer. First of all, generics in Java are not covariant, meaning that even though Integer is a subtype of Number, List<Integer> is not a subtype of List<Number>.
    While someone using putAll could pass a Map<Apple,Pears> one day, here and now the compiler assigns the artificial type names capture#1 and capture#2. While these are subtypes of K and D respectively, Entry<capture#1,capture#2> is not a subtype of Entry<K,D> according to the rule above. Consequently the assignment between the two is illegal. Wrapping Set around it makes it even worse.
    One mistake made easily goes as follows: Set<A extends Wine> is a set that in the future someone will use to store all kinds of Wine derivatives. THIS IS WRONG! The set will be used to store all kinds of A derivatives.
    Consequently, Entry<capture#1,capture#2> will, in the future be some very specific type. And this type is certainly not compatible with Entry<K,D>. This is why the closest possible variable definition proposed by Eclipse is Set<?>.
    A lot of in depth information about this stuff is provided by [Angelika Langer|http://www.angelikalanger.com/GenericsFAQ/FAQSections/TechnicalDetails.html]. While trying to answer your question, I also put together this.
    Harald.
    Edited by: pifpafpuf on Dec 6, 2008 7:05 PM
    Edited by: pifpafpuf on Dec 6, 2008 7:07 PM

  • NTRIALS Parameter Question...

    What exactly does the NTRIALS parameter of the FCSET command do? It can't be the number of regressions the the forecast engine goes through is it?
    Also, is this the correct forum for DML questions?
    Thanks for your time.
    GGA

    Greg, it took a little digging to find this one. I'm told that NTRIALS has no effect on the forecast, however it can be queried after the forecast to see how many trials can be reported by the FCQUERY function.
    Hope this helps. This is probably as good a forum as any for DML questions.

  • Simple parameter question ie db_name and usage in an expression

    Hi,
    I just started with SSIS with an example containing a flat xls file with 5 columns and a source table in sql.
    The example works fine no parameters etc.
    What I want to try out is to make an exception that if a certain db_name = X then the flow should be redirected to another table.
    Basicly I need help how to define a parameter to read from the source database like "select db_name as db_name" and use this in the package flow. When db_name=X then flow A ELSE flow B
    Any help is very appreciated.
    -Miracles are easy, the impossible takes a bit longer-

    Hi Paul,
    Create an object variable with name varObj and create a string variable with name as varDBName
    Use this as source query in execute sql tasK: Select <DBNamefield> from Table. In execute sql task do the following:
    On General tab: set Result set as Full Result Set
    On Result Set tab: Click Add and set Result Name as 0 and select varObj as Variable Name. This variable will capture the value returned from the select statement.
    Take a for each loop container and configure it as:
    On Collection tab: Enumerator: for each ado enumerator; ADO Object source variable: varObj; Enumeration Mode: Rows in first table.
    On Variable Mappings tab: Select varDBName as variable and set Index as 0.
    Inside the for each loop put the data flow task. Configure the data flow task and use a conditional split to redirect the rows based on varDBName as : @[User::varDBName]=="x" and so on for different outputs
    Nitesh Rai- Please mark the post as answered if it answers your question

  • Another multi value parameter question

    I have spent the last six hours researching and testing this and I am getting nowhere.  I am using CR 2008 and SQL Server 2005.  I have a main report that has a six level cascading prompt.  The values for all of the prompts are number values.  The lowest level prompt is a multi value prompt.  I need to pass the value(s) from this prompt to a subreport so I have created this formula field which I have seen in many of the posts:
    WhilePrintingRecords;
    Shared numberVar counter;
    //increments the loop so that all parameter entries can be displayed
    Shared stringVar display;
    //creates a string "running total" so that all entries can be displayed
    for counter := 1 to Count({?Hierarchy - DOUNum}) do
    display := display + ToText({?Hierarchy - DOUNum}[counter],0,";");
    display;
    I display this on my main form and I run across my first problem.  The first DOUNum is 19903 and the second is 19904.  What I see in the report though is 19,90319,904.  I need for it to be 19903,19904.  Before i knew the formula was doing this I passed this formula to my subreport for record selection there.  That subreport has the DOUNum field in it and that field is a numeric field, so when I try to put this in my record selection formula:
    {spCSSReportNCounts1;1.DOUNum} in [{?Pm-@DOUNum}]
    I get this error: A number range is required here.
    How in the world can I get around these two problems?
    TIA

    Okay, I have the formatting issue resolved.  Here is my new formula:
    WhilePrintingRecords;
    Shared numberVar counter;
    //increments the loop so that all parameter entries can be displayed
    Shared stringVar display;
    //creates a string "running total" so that all entries can be displayed
    for counter := 1 to Count({?Hierarchy - DOUNum}) do
    display := display & "," & ToText({?Hierarchy - DOUNum}[counter],0,"");
    Mid(display,2);
    This gives me 19903,19904 to pass to the subreport in my subreport link parameter - ?Pm-@DOUNum
    When I tried adding the = sign:
    {spCSSReportNCounts1;1.DOUNum} = {?Pm-@DOUNum}
    I get the error: A number is required here.
    And when I try this:
    {spCSSReportNCounts1;1.DOUNum} = [{?Pm-@DOUNum}]
    I get the error: A number range is required here.
    Which is the same error I get when i switch out the = for IN:
    {spCSSReportNCounts1;1.DOUNum} In {?Pm-@DOUNum}

  • Query parameter question

    Hi
    What are the diffrence of the query parameter in following format:
    select * from table_a where row_id=?id
    select * from table_a where row_id=:id
    select * from table_a where row_id=&idThe 1st and 2nd works if I use them as named query from Java (Toplink)
    The 2nd and the 3rd works when I use them from SQL developer. SQL developer will pop up parameter window. but the window looks diffrent with each parameter format.
    What are the diffrences?
    Thanks

    >
    select * from table_a where row_id=?idMust be a Java thing, not SQL or PL/SQL
    select * from table_a where row_id=:idThis is a bindvariable
    select * from table_a where row_id=&idThis is a substitution variable
    Edited by: Alex Nuijten on Jun 17, 2009 5:33 PM
    Edited by: Alex Nuijten on Jun 17, 2009 5:34 PM

  • SDO_GEOM.WITHIN_DISTANCE parameter question

    Hello,
    We are using a spatial function in our WHERE clause to determine whether Point A is within a certain distance of Point B. The call is:
    and SDO_GEOM.WITHIN_DISTANCE(s.location, 1000, n.location, 10) = 'TRUE'
    I can tell that the code is trying to see whether Point A is within 1000 units of Point B but what I'm trying to figure out what the unit of measurement is for the 1000 units. Could someone give me a pointer on where I can find the definition of this unit of measurement?
    Thanks for your time.
    Steve

    from the user guide:
    http://download.oracle.com/docs/html/B14255_01/sdo_objgeom.htm#sthref1756
    SDO_GEOM.WITHIN_DISTANCE(
         geom1 IN SDO_GEOMETRY,
         dist IN NUMBER,
         geom2 IN SDO_GEOMETRY,
         tol IN NUMBER
         [, units IN VARCHAR2]
         ) RETURN VARCHAR2; units
    Unit of measurement: a quoted string with unit= and an SDO_UNIT value from the MDSYS.SDO_AREA_UNITS table (for example, 'unit=KM'). See Section 2.8 for more information about unit of measurement specification.
    If this parameter is not specified, the unit of measurement associated with the data is assumed. For geodetic data, the default unit of measurement is meters.
    Note:
    1. that this is a function that does not use spatial index.
    did you in the where clause explictly defined pointa and pointb?
    if not, you should use the operator SDO_WITHIN_DISTANCE http://download.oracle.com/docs/html/B14255_01/sdo_operat.htm#sthref1150.
    Luc
    Edited by: lucvanlinden on Oct 1, 2008 8:26 PM

  • Subreport parameter question

    I have a report on liquor licensees that brings in zero to several values (extra license privileges)  in a subreport.  It works ok but I can't get a parameter/selection criteria to work.  I can get it to select based on the parameters, but when I don't put in any parameters I don't get any records, and when I put in all the choices, I get them, but I don't get the records with no extra license privileges, i.e., no records in the subreport's table.
    The report already has several parameters that don't draw from the subreport.
    I tried using a left outer join.
    I don't know if I have the subreport links right.  Right now I'm back to the beginning, without that parameter.  Will someone please help me?
    Edited by: Lauri Malone on Aug 21, 2008 10:46 PM

    Then I see two options:
    1. Conditionally suppress details section and here are the steps
    - have subreport in Details A section and pass subreports results as shared variable to main report
    - Conditionally suppress all other Details (B,C,D,.etc) sections based on shared variable
    2. Switch main report and subreport
    -Your current subreport could be a main report where based on parameters you can concatenate a list of records that you want to select.
    - Your current main report could be added as a subreport in Report Footer and list of records passed as a parameter in subreport links
    I am ready to explain details depending on which option you prefer

  • Parameter Questions 9i

    I need to attain the following information:
    Identify the database name, instance name, and size of the database blocks.
    List the name, location and size of the data files, online redo log files, and the name/location of the control files.
    List the current sessions active in the database.
    What would the command look like that would open a started/unmounted database as read-only.

    --database name
    select name from v$database;
    --db block size
    select * from v$parameter where name = 'db_block_size';
    --info on data file
    select * from dba_data_files;
    --info on log file and log group
    select * from v$logfile a, v$log b
    where a.group#=b.group#
    --control file location and status
    select * from v$controlfile
    --info on current session
    select * from v$session
    --when database in mount state
    alter database open read only;

  • MySQL Stored procedure, INOUT parameter question.

    Hello, I'm trying to run a stored procedure in MySQL 5.0 through the use of Java. Here's what I have:
    Part of my Java code (which is taken from the MySQL Connector/J documentation):
        CallableStatement cStmt = conn.prepareCall("{call demoSp(?, ?)}");                                   
        cStmt.registerOutParameter("inOutParam", Types.INTEGER);
        cStmt.setString(1, "hello");
        cStmt.setInt("inOutParam", 4);
        cStmt.execute();
        System.out.println(cStmt.getInt("inOutParam"));The stored procedure (which has been taken directly from the MySQL Connector/J documentation, PDF format, Page 4)
    CREATE PROCEDURE demoSp(IN inputParam VARCHAR(255), INOUT inOutParam INT)
    BEGIN
        DECLARE z INT;
        SET z = inOutParam + 1;
        SET inOutParam = z;
        SELECT inputParam;
        SELECT CONCAT('zyxw', inputParam);
    ENDI have tested the query in MySQL and the stored procedure does work correctly. The Java code successfuly runs the stored procedure, but the INOUT parameter always returns as 1. This behaviour indicates that when the stored procedure runs, inOutParam is set to 0, regardless of what value it is given in the Java code. Therefore, is the INOUT parameter fully supported? Maybe my Java code is incorrect?
    Thanks in advance for a response.

    I don't see anything obviously wrong with the code. That you are always getting 1 out, suggests the possibility that the input value isn't going in, is defaulting to 0 and 0+ 1 is being returned...
    As a guess, try doing:
    cStmt.setInt(2, 4);instead of:
    cStmt.setInt("inOutParam", 4);It could be that MySQL has some problems with "by name" parameters...
    Alternately, modify the stored procedure to put inOutParam into a table and see what value is being recieved...

  • Very simple Parameter question in Eclipse

    I simply want to create a report where a user can pick a date range at runtime.  I designed a simple report, added parameter fields and ran it in the designer.  It prompted me for dates and I filled them in.  The report ran in the designer just fine.  When I publish the report to the Apache Tomcat web site, I want the prompts to pop up for the user so they can pick the date range.  There are no parameters that pop up and the parameter panel shows NO parameters.  Can someone point me to a document or process that will allow me to prompt the user for these dates?  I am invoking the report from the JSP that is generated by the plugin.

    Are you passing paramete values in your code? If you do not then it will automatically asks for parameters.
    Regards,
    Tejaswini

  • Resource_limit parameter question

    If my resource_limit parameter is FALSE and i assign profiles have resource limit to users what would be effect?

    Since you have setted the Resource Limit as "False", which does not effect on Users which are having assgned profiles.
    Until you enable resouce_limit parameter toTRUE.
    Thanks
    Pavan Kumar N

  • AICC Parameter Question

    Hi Everyone,
    In OLM we are linking to a third-party provider that has AICC-compliant courseware. The provider requires that the URL have the following parameters:
    tid (our course name), aicc_sid (a unique session id), and aicc_url (the url that OLM monitors AICC commands and requests on)
    http://www.myprovider.com/aicc.asp?tid=coursename&aicc_sid=<AICC_SID>&aicc_url=<AICC_URL>
    Does OLM automatically append the required parameters for the aicc_sid and aicc_url parameters to the content's starting URL, or do they have to be specified manually in the URL of the content object?
    The aicc_url variable will change every session, so I'm not sure how to specify it, and just passing the course id and omitting the other two variables in the content URL does not work.
    Any help would be greatly appreciated!
    Thanks,
    Anne

    The AICC URL is typically constructed from the html file created by the content software (such as Adobe Captivate) and registered in Learning Management against a content server. When you create a learning object, you specify either a URL, or a combination of elements to build a URL: content server, directory, and starting file. That starting file is the html "wrapper" that the Learning Management "player" calls on to construct the AICC_SID and AICC_URL parameters appended to the URL that the e-Business Suite creates when a learner clicks the Play button. If you open that html file in a text editor, you will see these parameters. Typically, a content developer would provide a content package complete with content, perhaps in Flash format, and supporting files, including the html file. The AICC_SID parameter corresponds to the ATTEMPT_ID column in the OTA_ATTEMPTS table, which joins to OTA_PERFORMANCES on that column upon successful completion of the training.

  • COMPATIBLE parameter question

    Our company makes an application which needs the COMPATIBLE parameter set to 10.2.0.1.0 . But our client says its db's COMPATIBLE parameter is set 10.2.0.3.0 . The only application that is going to run in this server will be our application. Do we have to ask the client to change the COMPATIBLE parameter to 10.2.0.1.0 or let it remain as 10.2.0.3.0?

    On 10g the parameter COMPATIBLE cannot be downgraded, as once datafiles are open, they register this information on their headers.
    In this particular case there is no conflict with the versions, as you are talking about the same functional version with different maintenances:
    The first three digits refer to the major version and the functionality, meanwhile the last two digits refer to the DB and OS maintenance (bugs), but you are talking about the same version, 10.2.0.
    ~ Madrid

Maybe you are looking for

  • Issues with setting up ATT 3g. ATT reconizes the setup but IPAD 2 won't connect with 3g network

    Setup brand new IPAD 2 ATT wifi +3G.  Everything went smooth even setting up the ATT cellular data connect.  ATT reconized the purchase however the IPAD will not erconize the 3G function when the wifi is turned off.  I have an Iphone 4 and the 3G net

  • How to identify toll free numbers in CUCM

    Hi  I am new to this Cisco VOIP system. My Company has many toll free numbers. I need to know where can I find the toll free number details. I had a request today to alter few settings in them. But I dont know what to do and where to do.  Eg : 800326

  • Correcting OCR'd text misreads

    Hi everyone, I'm using Acrobat Pro 8. I've OCR'd a bunch of scanned documents and found that the OCR utility does tend to skip over some lines and other times it misreads text (and doesn't mark it as suspect). Is there a way to correct misread text?

  • Trigger and Gate Only Returns One Channel

    Hello all, I am trying to write a VI that will run in the background and start writing some data to a file when it detects a signal. For detecting the signal, the VI uses the "Trigger and Gate" express VI to see when the input voltage goes above a tr

  • SNMP configuration in WLC

    hi all, Can any one tell me if there is document available for SNMP configuration for WLC 4404?