Hello,
I'm learning one embedded system course online, and while watching one of those video, I had some doubts about pointer arithmetic,
while I was searching for answers I came across this...
Type: Posts; User: Athul
Hello,
I'm learning one embedded system course online, and while watching one of those video, I had some doubts about pointer arithmetic,
while I was searching for answers I came across this...
Hello
I have been trying to understand the code used in GcodeCNCDemo4AxisRAMPS, especially the algorithm used to draw a line. I have been reading several articles on Bresenham's line algorithm....
How come? here a is changing inside. So how could compiler ignore it.
Like when counter value reaches til a certain value?
eg:
if TCINT is a counter
Hello,
I have some doubts about compiler optimizing C code. This is more related to the field of embedded system.
int a, b;
void experiment() {
a = 8;
b = a * 7;
But the following code works
#include<stdio.h>
int a = 10, b = 20, c = 50, i;
int *arrop[3] = {&a, &b, &c};
SO how can I make above program work if it's global. I tied putting const before array
const int *arrop[3] = {p, &b, &c};
Where can I find more details about it?
Hello,
When an array pointers created inside the main, program works. But when I intialize array of pointers outside main, compiler gives error as
Initializer element is not constant
This...
In coming videos, he's using this method. I tried that code. But first variable is some junk value. I tried to understand his code by makeing a spreadsheet and trying to poin to various address,...
Tutorial - Google Drive
This is the link to the video.
Like I said further videos in this series make use of this tutorial
Hello.
I'm learning about creating a queue using double link list using a video tutorial. I wrote this code as seen in the video. I don't have the source file shown in the video. I checked the...
So when I assign memory using malloc(). they are placed in read and write memory, right??
So to sum up
When do as follows
int *p = 5;
here value 5 is treated as an address
Here I'm assigning s to "Hello"
char *s = "Hello";
s[0] = '0';
But this crashes program too
Why doing something like this okay
char *s;
s = (char *)malloc(100);
s[0] = 0;
but this crashes my program
This is &(ptr + i)->age in fact same as this &((ptr + i)->age)
That makes sense
Thanks
Thanks for the reply
Does this mean,
Int *p = 7
here 7 is treated as address, not as value??
Hello,
Some way the pointers are used confuses me.
When use as below
int a = 5;
int *p = &a;
#include <stdio.h>
typedef enum {
GREEN = 0,
BLUE
}COLOR;
typedef struct{
So just like creating a structure variable we can create a function that return a structure.
Can you show a simple example to me??
Hello,
I'm following this video Tic Tac Toe using c - YouTube to develop a Tictactoe game. In which the developer is using a structure and it's declared like this
struct myDataType {
...
Thanks for clarifying the difference
I understand how this works
struct person x;
scanf("%s%d%f", x.name, &x.age, &x.weight);
That was my question, need of & in ptr, even though ptr is already the address
In the first answer i got for this post
So, back to your question. It looks like &(ptr+i)->name is actually wrong....
changing this
for(i =0; i < num;++i)
{
printf("Enter name, age and weight of the person respectively:\n");
scanf("%s%d%f",&(ptr+i)->name,&(ptr+i)->age,&(ptr+i)->weight);
}
#include<stdio.h>
#include<stdlib.h>
struct person {
int age;
float weight;
char name[30];
};
int main()
{
Thanks for the reply.
Reason for I used %d instead of %p;
I'm learning some advanced topics of c from a Udemy course "Advanced C programming : pointers". In which instructor uses %d. The...