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 would like to purchase following book:

Simon, David E. An Embedded Software Primer. Second Printing. Reading, MA: Addison-Wesley; June 2000. 424 p.


I'm not looking for the older 1999 publication date.

Could someone provide me a link to purchase this item or is someone willing to rent, sell, or lend me their personal copy?
0
C++ 11 Fundamentals
LVL 13
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Consider Hello World program modified to illustrate embedded system Virtual Memory concepts:

#include <stdio.h>

   int bss_var;       /* uninitialized global variable */
   int data_var = 1;  /* initialized global variable */
   
   int main( int argc, char ** argv)
   {
      void *stack_var;    /* Local variable on the stack */
	  
	  stack_var = (void *)main;  /* Don't let the compiler optimize it out */
	  
	  printf("Hello, World! Main is executing at %p\n", stack_var);
	  printf("This address (%p) is in our stack frame\n", &stack_var);
	  
	  /* bss section contains uninitialized data */
	  printf("This address (%p) is in our bss section\n", %bss_var);
	  
	  /* data section contains initialized data */
	  printf("This address (%p) is in our data section\n", &data_var);
	  
	  return 0;
	  
   }

Open in new window


This program is created in BeagleBoard-xM running some Linux distribution.  This Linux distribution has vi editor and gcc compiler in it.
The line in the above program, "Don't let the compiler optimize it out", how do I make sure compiler doesn't optimize this line of code.  Do I need to compile
with some compiler option?
0
I purchased MCIMX8QXP-CPU: i.MX 8QuadX-Plus Multisensory Enablement Kit (MEK) from NXP.
https://www.nxp.com/support/developer-resources/evaluation-and-development-boards/i.mx-evaluation-and-development-boards/i.mx-8quadxplus-multisensory-enablement-kit-mek:MCIMX8QXP-CPU

This evaluation kit has some linux distribution that boots from SD card.  I use PC serial terminal program puTTy to communicate with this board.  I can see the file system is
mounted. I can type linux commands to navigate the file system.

I want to run 'Hello World' program in this board.  Using windows based PC, I used eclipse IDE with MinGW Toolchain (I installed gcc compiler from www. equation.com) website.  I created 'Hello World' program.   Is this gcc compiler intended for native use?  Or does it also apply to linux ?
If I can store my 'Hello World' executable in file system inside the board, will embedded linux execute this program?
0
I created a simple "Hello World" program in 'c' language using eclipse IDE.  I compiled with gcc compiler.  I'm getting compile error on -std=gnu14 option.  Please see attached.

Please provide some understanding on this compiler option.
error.PNG
0
Try to get some smart loops in C/C++ below:
Assume that we have a series: 2, 3, 4, 8.  Want to get the different sums of all combinations, that is
s1=2+3, s2=2+4, s3=2+8, s4=3+4, s5=3+8, s6=4+8, s7=2+3+4, s8=3+4+8,s9=2+4+8, s10=2+3+4+8. How about number of elements are 50 instead 4?
Can any gurus shed some light to it?
0
I have a set of lights ws2812 tha are addressible using the FASTLED library on a Arduino writen in C .

The code below makes this animation:  ○◙○◙○◙○◙○◙○◙○◙○◙○◙○◙○◙○◙○◙○◙○◙○◙○◙○◙○◙○◙○◙○◙○◙○◙ --------->  on a LED strip

The lights are working great in its current direction. I need the lights to travel now in the opposite direction.  Thank you.

#include <FastLED.h>

// Define the array of leds
#define LED_DT 3
#define COLOR_ORDER GRB
#define LED_TYPE WS2812
#define NUM_LEDS 38
uint8_t max_bright = 255;
struct CRGB leds[NUM_LEDS];


void setLEDs (int K, int N) {
  FastLED.clear();
for (int i = 0; i < NUM_LEDS; i++) {
    //( int i = NUM_LEDS-1; i >=0; i–-)  //  tried this but it didnt work
    if (i % N == K) leds[i].setRGB (0, 0, 250); // set red LED
  }
  FastLED.show();
}

void setup() {
  delay (1000);
  LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS);
  FastLED.setBrightness(max_bright);
}

void loop() {
  int N = 5;
  for  (int i = 0; i < N; i++) {
    setLEDs (i, N);
    delay (150);
  }
}

Open in new window

0
If you had to consider all the myriad of stock trading indicators out there that many novice and advanced traders alike base their trading on, and you had to group that huge number of indicators into the broadest possible major categories, what would those categories be?

I'm thinking there may only be two (2) categories off the top of my head:  Price and Volume.

What do you think?
0
Hello experts.
I got an image size 150 x 150 pixels BMP or JPG
when I make it bigger using mspaint or paint 3d

it loses resolution, becoming bigger blurry

is there any software or visual c, or visual basic source
that i can use to make it  sharper again?
Regards,
0
Please explain Gamma Compression algorithms. How to write Gamma Compression algorithms for typical video and image processing system?  Please provide some detailed examples.  How to gain sufficient understanding to be able to write Gamma Compression in 'C' or MATLAB?
0
Using Windows Forms

I have a tabcontrol , each page has a datagridview.  I know the  tab page name

tabData.SelectedTab.Name

let's say I have tabPage1  the datagridview on that tab is dgvPage1.   Now I want to get the selected row

int row = dgvPage1.CurrentCell.RowIndex;  


How can I do this if all I know about is the grid I want is   -- String  VariableName  =  "dgvPage1"  stored in a variable.

int row = (VariableName).CurrentCell.RowIndex;  
String Person = (VariableName).Rows[row].Cells[0].Value.ToString();
0
Your Guide to Achieving IT Business Success
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

I found this code in the Open Source code for Wireshark, and it appears it is returning a local variable, which I thought was not allowed, since the variable goes out of scope once the routine returns.

However, since it's a static routine, maybe that makes it OK,

Is it OK to return a local variable from a static function?

static GSList* local_interfaces_to_list_win(void)
{
	GSList *interfaces = NULL;
...
	return interfaces;
}

Open in new window

(This is C code.)
1
Hello

How can i pass an argument to a visual studio .exe (C++ project) from the command line i.e. cygwin?

Please note that I do not want to pass the argument via the Visual Studio GUI under debugger->Command Arguments.

So I would like something like this:
cygwin>a.exe 4

thanks
0
Hi all,

  I do want to store  "directory path" as a  key and corresponding value as a value. The key would be 1024.

  If I take std::map, I guess it would be performance hit with huge number of entries.

  It has to maintain this ds inside kernel module. What is the best ds to implement this in C++ 11?

Thanks,
Bvm.
0
With Lilypad e-textiles do you have to pair an Arduino board (nano or uno) with it or are these programmable themselves with Arduino software.  I have multiple LilyPad Arduino Simple Snaps and would like to program them to allow a student to push a button and have led lights go off in succession.
We are attempting to make interactive maps like what you would see in a museum.  Button goes off and the lights light up an army path or the outline of a state.
0
Hi,

I want to put a project I am writing on GitHub for public viewiewing.
What I want to make sure is no private information is in there.
I know my code does not have any references in there.

So things I am concerned about are.

My microsoft account email address
My azure devops Repos path - e.g. https://dev.azure.com/Code/Project/_git/xxxx etc
+ anything else I am not aware of.

I am assuming I would need to remove a git subdirectory somewhere.

Anything else - any other hidden files etc?

My original code is in Azure Devop's at the moment.
I am happy and prefer if I can not to have all the history there.

Which is why I was thinking of manually uploading it all.

Any thoughts / ideas.

Thanks,

Ward
0
I have a problem running any c programming using Widnows 10 command prompt, gcc ver is 3.4.2
please help
gcc: Internal error: Aborted (program collect2)  
Please submit a full bug report.
See <URL:http://www.mingw.org/bugs.shtml> for instructions.
0
Dear all,

Using Turbo Pascal or C or Turbo C (well primitive), how I read several columns with numbers from a text file and give the sum of each one?

Thank you in advance (if I found anyone that have programmed in Pascal.
0
IOS project using swift
On my story board I have a launch screen that is the entry point. Now I want another view controller, I drag a view controller onto the storyboard. I create a cocoa touch class that is a subclass of UIViewController, naming it DTViewController. On storyboard, I select my new view using the left most icon on the top of the view and go to custom class. I select DTViewController as my custom class.  To stop warnings about my view being unreachable I check "Use StoryboardID" and enter MyDeskTop as the Storyboard ID. I drag a label onto the new view.

I have the following code in AppController.swift
private func handleAppState(){
if let user = Aut.auth().currentUser{
let vc = DTViewController()
rootViewController = NavigationController(vc)
} else {
rootViewController = LoginViewController()
}
}

Open in new window


When I run the app the splash screen appears and then the DTViewController appears. The problem is it's not picking up on the View in the Storyboard, just the DTViewController class. My evidence is the label doesn't show up but if I change the background color in code in DTViewController the change shows.

What am I doing wrong?
Thanks!
0
Error messageHello Everyone,
I hope you all are doing well.  Attached, I have a Visual C ++ error message that a user got when he was at a work training.  He claims that other people were able to use it just fine.  I am waiting to hear back to see if there is anything different with their computers as compared to his.  The program is contained in a folder with a bunch of system files that application calls upon, it is not installed on the computer itself.  I and another tech got a copy of this folder and we get the same error message.  We are going to play around with it and see if we can make this work somehow.  I am just wondering if anyone knows about this.  
The user's computer is running Windows 7 pro
My computer is running Server 2016 Datacenter
my co-worker's computer is running Windows 10 pro

 If you guys think it an issue with the software itself, please let me know.  Any kind of programing fixes that people give me, I will not understand as I am not a software developer and if the fix comes down to that I will simply say that the developers need to fix this.

Thank you guys!!!
0
Introduction to R
LVL 13
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

ANSI c on OSX 10.13.6 <br>
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix

I'm learning `c`

This is a function that manually (character-by-character) adds two character strings representing large numbers (that exceed the unsigned long long or double size).

It functions fine with any two strings 14 or less characters long, but segmentation fault 11 with any strings greater than 14 chars.

Changing the string's memory allocation method seems to have no effect (I.e. from
char[15] addend1; // not a ptr

Open in new window

to
char *addend1 = (char *) malloc(sizeof(char) * (16) ); // pointer

Open in new window


One things that's curious, is that it seems to segfault on the ...
for (int j = maxlength - 1 ; j >= 0; j--)

Open in new window

... prior to accessing either of `addend1` or `addend2`, but I'm not able to find an error there or change it to prevent the segfault.  

Am I misreading where the error arises, or could it be related to the for loop?

MAIN.c

	#include <stdio.h>
	#include <stdlib.h>
	#include "../../c-library/include/addViaStrings.h"
	
	int main(void) {
		//	s[0] = 72; s[1] = 101; s[2] = 108; s[3] = 108; s[4] = 111; s[5] = 32; s[6] = 87; s[7] = 111; s[8] = 114; s[9] = 108; s[10] = 100; s[11] = 0;
	
		// WORKS
		// char s1[] = "14073748835532";
		// char s2[] = "14073748835532";
	
		// FAILS
		char s1[] = "140737488355328";
		char s2[] = "140737488355328";
	
		char *sum = addNumericStrings(&s1, &s2);
		printf("main.sum = %s\n", sum);
	}

Open in new window


addViaStrings.h


Open in new window

0
Hi I have a 2D vector in a library which gets populated with different types of data this part is working fine now I need to pass the 2D vector back to my main app from a function call but this function call is failing

Here is the structure that makes up the vector in the library and how I am trying to call the data in the vector from a function:
//Library code
typedef struct _DEVICEDETAILS
{
	std::string IPaddr;
	int HTTPPort;
	int HTTPSPort;
	int RTPSPort;
	std::string Model;
	std::string Name;
	std::string token;
	std::vector<std::string> RSTPURL;
	std::vector<char*> data;
	std::vector<size_t> datalen;
	std::string _mediaXaddr;
	int Encoding;
	int Width;
	int Height;
	int Quality;
	int FrameRateLimit;
	int EncodingInterval;
	int Bitrate;

}DEVICEDETAILS;

struct ONVIFDEVICE
{
	std::string MacAddr;
	std::vector<DEVICEDETAILS> _videotype;
};

ONVIFDEVICE m_MacAddr;
std::vector<std::vector<ONVIFDEVICE>> v_Device;

void GetOvifInfo(std::vector<std::vector<ONVIFDEVICE>> &returnInfo)
{
  other code .......
   int m_size =v_Device.size();
   v_Device.resize(m_size+1);
   v_Device[nFindDev].push_back(m_Mac); // info gets populated into each element here
   nFindDev++;
   
  //Need to do a deep copy from vector v_Device to  vector returnInfo

}

// Main App code
typedef struct _mDEVICEDETAILS
{
	std::string IPaddr;
	int HTTPPort;
	int HTTPSPort;
	int RTPSPort;
	std::string Model;
	std::string Name;
	std::string token;
	std::vector<std::string> RSTPURL;
	std::vector<char*>

Open in new window

0
I have a Dell 5810 workstation with Win 10. Drive c: = 1tb ssd. Drive d: = 1tb ssd. I have slots for two mechanical drives. One has failed and instead of replacing it with one 6 tb drive I was wondering if I purchased two 4tb WD black drives and used them in a raid 1 configuration that it would be my best solution. I do not need speed on the two mechanical drives. They would essentially be shown as a single 4tb drive, each with the same exact data for safety. I spoke to Dell and they said it is definitely possible. I do not want to affect my c or d drives at all. So, my question is: What software is super simple to use in order to implement raid 1 on the two new identical drives?
0
I have following version of eclipse IDE installed in my computer:
Eclipse IDE for C/C++ Developers
Version: 2018-09 (4.9.0)

I created a workspace.  There are number of Templates for New C / C++ Project.
I need to import very large 'C' source code files into my project.  I won't be compiling code in eclipse.  I'll just be navigating source code.
Which Project template should I select?  Is there a way to create project without selecting a project template?
0
Actually the file descriptor table is not a real table. It's just an array of pointers to the "open file table" (struct file). But let's say we will see it as a table. What are the columns? For example:

FD   | Pointer to "open file table"
----------------------------------
...  | ...

In short, that's the question. I see a lot of different figures on the internet, but they are all different. For example, see:

http://faculty.winthrop.edu/dannellys/csci325/10_shared.htm
There they have a column "fd flags" (read/write), but I would think that this column is part of the "open file table" and not part of the "file descriptor table". See for example: http://man7.org/linux/man-pages/man2/open.2.html


       A call to open() creates a new open file description, an entry in the
       system-wide table of open files.  The open file description records
       the file offset and the file status flags (see below).  A file
       descriptor is a reference to an open file description; this reference
       is unaffected if pathname is subsequently removed or modified to
       refer to a different file.  For further details on open file
       descriptions, see NOTES.

       The argument flags must include one of the following access modes:
       O_RDONLY, O_WRONLY, or O_RDWR.  These request opening the file read-
       only, write-only, or read/write, respectively.
0
I'm trying to investigate a problem with resource files generated by Google Omaha. These resource files contain a place-holder token (%1!s!), which is substituted with branding details during the build process. There are numerous language resource files that contains string tables and this

Here is an example string: "%1!s! some arbitrary text"

Where %1!s! is a place-holder for some substitution text?

My question: is this place-holder substitution mechanism a standard part of the Windows resource file mechanism? If so, can someone please either explain how it works? Where does it get the text used to substitute the place holder? I'm assuming the place-holder works similar to place-holders in printf? If so, how does it know which text token to replace this with? If this is not a standard resource file mechanism, does anyone have a clue as to how Omaha does this during the build process?

Many thanks.

Note: I'm not looking for suggestions to use a different approach. This is how Omaha does it and I just need to understand how this works. Thank you.
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.