C

22K

Solutions

13K

Contributors

C is a general-purpose, imperative computer programming language, supporting structured programming, lexical variable scope and recursion, while a static type system prevents many unintended operations. By design, C provides constructs that map efficiently to typical machine instructions, so it has found lasting use in applications that had formerly been coded in assembly language, including operating systems as well as various application software for computers ranging from supercomputers to embedded systems. It is distinct from C++ (which has its roots in C) and C#, and many later languages have borrowed directly or indirectly from C.

Share tech news, updates, or what's on your mind.

Sign up to Post

I'm chasing what I think should be an obvious issue, but I can't find it.

The host is a Pogoplug E02 running Debian jessie.

Logged into the system as root, the following two commands turn the green LED on and off as expected.

root@www:# echo "default-on" > "/sys/class/leds/status:green:health/trigger"
root@www:# echo "none" > "/sys/class/leds/status:green:health/trigger"

Open in new window


Below is a little program adapted from one at https://github.com/suetanvil/ledflash/blob/master/ledflash.c.  To my mind this code should blink the green LED on and off a few times:

#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <syslog.h>
#include <string.h>
#include <sys/stat.h>

#   define FLASHFILE   "/sys/class/leds/status:green:health/trigger"
#   define ON          "default-on"
#   define OFF         "none"

void main() {
    FILE *ledfile;
    int status;

  ledfile = fopen(FLASHFILE, "w");
  if (ledfile == NULL) {
    printf("Unable to open '" FLASHFILE "' for write\n");
    printf("Error: %d (%s)\n", errno, strerror(errno));
    exit(0);
  }

  status = fputs("none", ledfile);
  sleep(1);
  status = fputs("default-on", ledfile);
  sleep(1);
  status = fputs("none", ledfile);
  sleep(1);
  status = fputs("default-on", ledfile);
  sleep(1);
  status = fputs("none", ledfile);
  sleep(1);
  status = fputs("default-on", ledfile);
  sleep(1);
  status = fputs("none", ledfile);
  sleep(1);
  status = fputs("default-on", ledfile);
  sleep(1);
  status = fputs("none", ledfile);
  sleep(1);
  status = fputs("default-on", ledfile);
  sleep(1);
  status = fputs("none", ledfile);

  exit(0);
}

Open in new window


The program's effect is exactly nothing. No error on the LED device file open, no blinking LED.  Clearly something is different between echoing the command from a console prompt, and writing it to the device from a program.  I don't know what it might be, though.

Any ideas?
0
Technology Partners: We Want Your Opinion!
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Can anyone help with this?  I am porting a legacy c program from UNIX Tru64 to Intel64.  I have not had any luck in mapping the following options:
-source_listing
 -assume noaligned_objects
 -D_INLINE_INTRINSICS
-show source, header, statistics  

The complete compile options line is as follows:
 Tru64
 CGFLAGS=-source_listing -show source,header,statistics -assume noaligned_objects -O0 -D_INLINE_INTRINSICS

Intel64
I have identified -O0
I have not identified:
-source listing   I don't believe this is critical
-show source,header,statistics   I found -xc for source, but header is not the same, and nothing on statistics.
-assume noaligned objects   No information
-D_INLINE_INTRINSICS  No information
0
Passing from RPGLE INT 10i 0 to C function
D Functx           pr                  ExtProc('C_FUNCTX')        
D  LenOfRcvVar           10i 0 const                              
D  InfoFmt                      8A   const                              

D WkSizeOfFmtX    s             10i 0
D WkFmtName8      s              8    

WkSizeOfFmtX    = 4520

 Functx (WkSizeOfFmtX:
               wkFmtName8);  

 extern "C"                            
 void Funct_x                          
          (int  info_size,
                const char* info_fmt);

Value of info_size always 2 ???  - why???   Could the field after the INT affect the value ???
0
I am currently looking for a way to detect if the "Pause Printing" option in the "See What's Printing" window is checked in Windows.

I've searched high and low, and looked into the Win32 native printing API (winspool) to see if there was such a detection available, but to no avail.

Is there anyone who has experience with a successful implementation of this detection?

I'm looking for a solution in either C/C++, or C#.
0
Hello!

I have a database (attached) and I want to be able to export the first two sheets to a PDF. However, the code I have now (below) which runs after clicking the Print Bid button, only converts part of the first worksheet. When the user is using this database there could potentially be many more work items and therefore I need the code to convert everything in all the columns to a PDF, except column C. That is the next problem, the Jump To column, column C, in the first worksheet should not be visible in the PDF but right now, despite the code, it is. If anyone has any suggestions on how to change these two things that would be wonderful! Thank you!

Sub PrintToPDF()
    Dim oWs As Worksheet
    Sheets("summary").Columns("C:C").EntireColumn.Hidden = True
    Set oWs = Sheets("summary")
    With oWs.PageSetup
        .FitToPagesWide = 1    ''/// prints to one page
    End With

    oWs.Columns("C:C").EntireColumn.Hidden = False

    With Sheets("service rates").PageSetup
        .FitToPagesWide = 1    ''/// prints to one page
    End With
    ''///Save the Array of worksheets (which will be selected) as a PDF
    ThisWorkbook.Sheets(Array("summary", "service rates")).Select
    On Error Resume Next
    oWs.ExportAsFixedFormat _
            Type:=xlTypePDF, _
            Filename:="Test.pdf", _
            Quality:=xlQualityStandard, _
            IncludeDocProperties:=True, _
            IgnorePrintAreas:=False, _
            …
0
I'm programming Infineon TC29x Aurix Tricore Microcontroller based embedded system in 'C' language.  

Consider stack starting address 0x5000 0000.  The stack size is 0x2000.  

If I take current stack pointer minus 0x2000, will that create stack exception?  If yes, what might be 'C' or assembly language code that will achieve this?

My thought is if I subtract negative 0x2000 from current stack pointer or add 0x2000 to current stack pointer, I'll be outside stack and stack exception will occur ?

 I need to set program counter to illegal address, i.e. 0x00FF FFFC.  Can this be done with assembly language instructions?
 If yes, please instrument assembly language instruction that would set program counter to 0x00FF FFFC while code is running.
0
I would like to implement a fast fixed point sine approximation for PIC24F microcontrollers on 16bit.
I started from here: http://www.coranac.com/2009/07/sines/
The approximation is done with polynomials: 3rd order up to 5th or even 6th order.
I am stuck in the beginning.
The 3rd order polynomial is S3(x)=(3/PI)*x-(4/PI^3)*(x^3) or S3(z)=(1/2)*z*(3-z^2) with z=x/(1/(2*PI))
I tried an Excel sheet for this function and I compared with sin() from Excel.
Either I make a mistake or the approximation error is too big.
Here is the Excel: https://goo.gl/2KJXj8 
Could you help to debug this?
0
We are using TC29x Microcontroller. The flash size is 6Mbytes. There are Three banks, 2Mbyte each.

Program Flash 0 (PF0) is bank 1. Program Flash 1 (PF1) is bank 2. Program Flash 2 (PF2) is bank 3.

 PF0 address range is: 0x8000 0000 - 0x801F FFFF
 PF1 address range is: 0x8020 0000 - 0x803F FFFF
 PF2 address range is: 0x8040 0000 - 0x805F FFFF

 Where is Program Flash ECC stored. Is it within 6Mbyte ? Or is there additional storage space for ECC that we don't have access to ?

 How does Flash ECC work ? For how many bytes of data, how many bytes of ECC are there ? Whenever we write to flash, ECC updates? When we erase flash ECC updates?

 How is it possible to create Flash ECC Error ? Because everytime you write or erase flash, ECC will update?
0
Hi,

I have a C program which would be doing some task and returning a value to me. I would like to capture this value either in CL or in Java code. Anyone having any idea how I can accomplish this?
0
I am a C#.NET ASP.NET Web/Windows developer. And I know a bit of Objective C from the iPhone app which I helped to write. I even started an Android version with Java. But I would never use those languages ever again to get support on one platform.

So, now that .NET CORE supports many cell platforms, I MAY write my next mobile app.

What platforms are supported? What technologies are needed to write an iPhone app?

And Android app?

Is this a .NET Website? Otherwise please explain a bit about what CORE is all about?

I have a Mac, so I would run Visual Studio on El Capitan, I presume.

I am really excited about this, so please let me know...


Thanks
0
[Live Webinar] The Cloud Skills Gap
LVL 4
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Hello!
I am trying to free up C drive space by cleaning up items from the Winsxs folder using the Disk Cleanup utility which I installed from the server features. However, there does not appear to be an option to cleanup the Winsxs folder in the utility as there is in the R2 options. Can someone tell me how I can go about cleaning up space in the Winsxs folder given this? I have folders in there from 2008 and I figure I surely can delete at least a chunk of this folder given the ages of these folders (I have not plans to rollback to those updates :D)
0
How to add to the right side of table A ,  the colums and data of 2 other tables B and C .
Example:
table A: col1 (pk) , col2  -- 10 rows
table B: col3 (pk) , col4  -- 10 rows
table C: col5 (pk) , col6  -- 10 rows

Each table have all pk values that exist on the other 2 tables.

the result should be as follows:
table A: col1 (pk) , col 2 , col4, col6
0
i need to read a path from a dll created in visual studio c++ 2010 in LABWINDOWS CVI (C)
.h is
 #ifndef IMAGE_H_
#define IMAGE_H_   

#ifdef COMPILING_DLL  
#define DLLEXPORT __declspec(dllexport)  
#else  
#define DLLEXPORT __declspec(dllimport)  
#endif  

#ifdef __cplusplus
extern "C" {
#endif

DLLEXPORT char* __cdecl read();

#ifdef __cplusplus
}
#endif

#endif[

Open in new window


and .cpp

#include "D:\opencv3.0\opencv\build\include\opencv2\highgui\highgui.hpp"
#include "D:\opencv3.0\opencv\build\include\opencv2\core\core.hpp" 
#include <iostream>
#include "image.h"
#include <stdexcept>

#define COMPILING_DLL
using namespace cv;
using namespace std;


	char*__cdecl read()
{char* path = " C:\\Users\\eouerten\\Desktop\\visual_cvi\\essai_visual_cvi\\essai_read\\cat.jpg";
    Mat mat = imread(path, CV_LOAD_IMAGE_UNCHANGED); //read the image data in the file "MyPic.JPG" and store it in 'img'

    if (mat.empty()) //check whether the image is loaded or not
    {
        cout << "Error : Image cannot be loaded..!!" << endl;
        //system("pause"); //wait for a key press
        return path;
    }
	}

Open in new window


the main .c is

#include <ansi_c.h>
#include "image.h"

int main()
{

    char* p=read();
    getchar();
    printf("l'adresse de l'image est %s" ,p);
  return 0;
}

Open in new window

Result : build succeeded but the problem that i can't run it :erreur 0xc000007b i verified all dll like mscvp100.dll but it's not the problem
0
I have a file that has a header record in A1 and a trailer record in it at the end.  The lines between is the data I want to edit that start in Cell A2.  So Header record in A1 then Data in A2 then A3 then A4 and so on until it gets to the end with the last record being the trailer record.

What I want the macro to do is look in the file (attached as Data) and go to the first record in A2 and get the number in positions 43 through 48.  Then look in the Reference file and find that number in Column A and get the 2 digit code in column C.  Then go back to the record and replace positions 74 and 75 with that information.

So if I look at cell A2 in the data file and count over to positions 43 - 48 I get   321482
Then if I look in the Reference file and find that number I see in Column C the information is   5A
Then knowing 5A is what I want to replace I go to the record in the data file and count over to position 74 and 75 I see the value in there is 48.
Then I replace the 48 with 5A
Then I need to move to the next record and do it. and the next record, and the next record etc.

Hope this is detailed enough and a macro is possible.  Thanks in advance.
Data.xls
Reference.xls
0
Hi experts,

I have the following question

I have an array

vector<long> v = {5,7,2,10,4,6};

I did the Bit wise operation & of the first 4 numbers

5&7&2&10 = sum

now I need a sliding window i.e.
compute 7&2&10&4

I need  to perform the operation by removing first element and adding last element , how can I achieve that using bitwise operations ?

   something like  newSum =  ???sum&4,

I tried newSum = (~7)|(sum&4) but it gave a negative result .

Thanks
0
Hi Guys,

I need help to perform the following
I have a the following class that has 3 functions with same name but different parameters type
class A : public ParentClass {
 void handleEvent (EventA ){}
void handleEvent(EventB){}
void handleEvent(EventC){}
}
Is there a way to store them in a map as function pointer and then call them back based on the type of event received ?

I was going to do :
Map<string, void*> map;
Map[eventAId] = &handleEvent  // here is the issue all the functions have the same name
Is there a way to fix that ?

I am using C++ 11 and stl library.
0
Hi we recently upgraded our SCCM 2012 sp1 server to 2012 R2 SP1 console version 50.0.8239.1502, site version 5.00.8239.1000. The problem we having now is that the existing deployments are just stopping at the point where the task sequence would install applications. we logged a call with Microsoft but that's not getting us anywhere thus far. The funny thing is I found a post online about it creating an _sms task sequence folder on the c drive and then failing when trying to read from the folders on the local drive. Basically it fails without an error once the client gets installed, I simply get prompted to restart the machine via a countdown which is part of the task sequence. We have office, adobe and two device driver installations that are meant to carry on after that point, but it never gets that far. The network access account is working fine and can access the source content, so I'm stumped. please help.
0
Hi guys,

I want to keep track of class structure ( parent /child relationship) and keep them in a tree structure. Something like this one  ( with the difference that I may have different levels of parent/child relationship).

http://stackoverflow.com/questions/10589779/enumerating-derived-classes-in-c-executable

Thanks
0
Hi all,

I occur an error when i try to buid the following C code.
I'm newbie in c programming.
Please HHHHelp me .


#define JOUEUR_1 1
#define JOUEUR_0 0
#define JOUEUR_VIDE -1
#define PIECE_NON_PROMUE 0
#define PIECE_PROMUE 1
#define FAUX 0
#define VRAI 1
#define VIDE -1
#define T 11
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
struct piece_s
{
int joueur;
int type;
int statut;
}; typedef struct piece_s piece_t;

struct coordonnees_s
{
int x; // ligne du tableau;
int y; // colonne du tableau;
}; typedef struct coordonnees_s coordonnees_t;

typedef struct coup_s coup_t; //maillon de coups
struct coup_s
{
	coordonnees_t depart; //sauvegarder les coordonees de la piece de depart
	coordonnees_t arrivee; //sauvegarder les coordonnees d'arriver la piece
	int promotion; //booleen
	int capture; //booleen
	coup_t *suivant;
	coup_t *precedant;
};

struct liste_s
{
	coup_t *debut;
	int nb_de_coups;
	coup_t *fin; //ladresse de fin du dernier maillon
}; typedef struct liste_s liste_t;

struct partie_s
{
	piece_t tablier[T][T]; // T=taille
	liste_t coup_joue;
	int bool_joueur;
	int joueur;
}; typedef struct partie_s partie_t;

typedef struct maillon_capture_s maillon_capture_t;
struct maillon_capture_s
{
    coordonnees_t depart; //sauvegarder les coordonees de la piece de depart
	coordonnees_t arrivee; //sauvegarder les coordonnees d'arriver la piece
    int promotion; //booleen
	int capture; //booleen
	coordonnees_t coord_capture;
	

Open in new window

0
What does it mean to be "Always On"?
LVL 4
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

how to convert from std::wstring to wchar_t*
0
Given struct A, what is the difference between these two initializations?

//begin code

C c1 = {0};

C c2 = {0,};

//end code

Yes, I see some places where they initialize with a zero and a comma.
0
I had this question after viewing pthread blocking queue.

I want to use the following queue in order to create a worker thread that consumes the events pushed to its queue.
I want it to be generic so that it can be easily reusable whenever needed by just inheriting from it.
0
Hi Experts,

I am trying to solve the following problem:

I have been given a list of fractions like 1/2, 2/3 , 3/4 ...
The way these number will be added is like this e.g. :  1/2 + 2/ 3 = (1+2)/(2+3);

I need to find the best sequence so that I can maximize the total sum.

Can you guys point me to any hint or help or theory behind this problem ?

Thanks
0
I have three drop down
state
county
city

all above in asp.net drop down and the data source is WCF.
I would like to see like if CA is selected, it will response back with like Los Angeles, and when the county is changed, it will show me the list of c city.

How can I do that?
0
In my binary tree, I can delete values that have other values extending from it. If they don't, or if it is the only value, the program crashes. Not sure how to fix it. This is the deletion part of the code:

void delete_tree (binarytree *t, int x)
{
   binarytree temp;

   if (!is_empty(*t))
   {
       if (x == (*t)-> data)
       {
           if (((*t) -> left == NULL)&&((*t) -> right == NULL))
           {
               temp = (*t);
               (*t) = NULL;
               free (temp);
           }

           if (((*t) -> left != NULL)&&((*t)-> right == NULL))
           {
                temp = (*t);
                (*t) = (*t) -> left;
                free (temp);
           }
           if (((*t)-> left == NULL)&&((*t)-> right != NULL))
           {
               temp = (*t);
               (*t) = (*t) -> right;
               free (temp);
           }
           if (((*t) -> left != NULL)&&((*t) -> right != NULL))
           {
               temp = (*t)-> right;
                   while (temp -> left != NULL)
                       {
                           temp = (*t) -> left;
                       }

               temp -> left = (*t) ->left;
               temp = (*t);
               (*t) = (*t) -> right;
               free (temp);

           }

       }
       else {
            if ( x <= (*t) -> data)
                delete_tree(&(*t) -> left, x);

            else
                delete_tree(&(*t) -> right, x);
        }


   }
   else 

Open in new window

0

C

22K

Solutions

13K

Contributors

C is a general-purpose, imperative computer programming language, supporting structured programming, lexical variable scope and recursion, while a static type system prevents many unintended operations. By design, C provides constructs that map efficiently to typical machine instructions, so it has found lasting use in applications that had formerly been coded in assembly language, including operating systems as well as various application software for computers ranging from supercomputers to embedded systems. It is distinct from C++ (which has its roots in C) and C#, and many later languages have borrowed directly or indirectly from C.