473,883 Members | 1,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Seriously struggling with C

RG
Greetings friends,

This semester I have started a course in C programming. I was moving
along fine until I reached to the topic of loops (feeling embarrassed
among you elite programmers). My prof. would post program questions
and the solutions online. For practice I would try to do the problems.
I would reach to a certain point in the code, for example as far as
error trapping, but when the loop arrives, like knowing whether to use
for, while do, how to properly use the increment and decrements, and
counters,I am just not proficient in it and the class is moving ahead.
Eventually i would have to look at the solution and wondering to
myself, the reason i could not think of it. What ticks me off is that
other kids are getting this stuff easily, while I am having a hard
time.Kindly advise me on what actions I shoul take. I would
particularly like to have an idea of the thought process to engage in
when given the programme to write.
Thanks for your time and consideration.

RG

Feb 20 '06
160 4807
On 2006-02-22, Nick Keighley <ni************ ******@hotmail. com> wrote:
Richard G. Riley wrote:
I must admit to hating array notation.


A_buffer[6] = (unsigned char) ((buffer[3] & 0xfc) |
((buffer[4] >> 6) & 0x03));

*(A_buffer + 7) = (*(buffer + 4) & 0x1f) |
((*(buffer + 4) << 2) & 0x80) |
((*(buffer + 3) << 5) & 0x60);
memcpy(A_buffer + 8, buffer + 5, 5);
:-)


lovely :)
--
Remove evomer to reply
Feb 22 '06 #51
Richard G. Riley wrote:
On 2006-02-22, Chris Dollin <ke**@hpl.hp.co m> wrote:
Richard G. Riley wrote:
On 2006-02-21, CBFalconer <cb********@yah oo.com> wrote:
Yet you are willing to eliminate the clarifying blanks in the
statement. At the same time I cannot remember when I last used a
debugger in anger. printf usually is adequate.

You are joking?


Why should he be joking?


His comment was "cannot remember the last time" : clearly a very
personal thing. Not somethign to recommend or aim for IMO.


/I/ think it's something to aim for.
Littering code with printfs or the quivalent plain sucks unless its
for logging purposes and is well DEFd out : even then it can
unecessrily break p the flow and readability of the code.
I don't know what CB does: I do know that I don't leave debugging
printf in code. I will leave logging statements in code, but I use
precious few of those either. (The distinction is just that the
logging stuff is for some switchable record of things that happen,
which need not be for debugging but for explanation or exposure.)
Its why debuggers exist. Only the most trivial
or tiny code can be maintained or properly examined with messy and
time consuimg printfs.
Well ... will you count specialised output functions as logical
printfs? Because those were my tools of choice when I needed to see
internal state of code under development. Perhaps my code was tiny,
or trivial, by your standards - but I would have described using a
debugger on it as an act of madness.
printfs only show what you *think* you need to
know : not the true state of memory, locals, stacks, memory blocks.
I've never found that to be a problem.
In addition printfs dont give you watchpoints, breakpoints etc. I cant
even believe we are having this discussion to be honest, although I
suppose you're not necessarily defending it : just that it can be done
- on that we are agreed.


Oh, I /am/ defending it. In my (limited) C experience, I have not
needed to resort frequently to a C debugger. I would expect to need
one less nowadays than I used to, as well.
The last C project I did - a compiler/shortcode interpreter for
a scripting language - I hardly used a debugger at all, and when I
did, it was to get a stack-trace and line-number because that
doesn't happen for free when the code went whoopsie.


If you can get away with it fine. Its certainly not something that
would generally be encouraged in any programing environment I have
been involved in.


Developing code in a way that doesn't require using a debugger wouldn't
be encouraged? Really?

I suspect we have some fundamental disconnect somewhere. Debuggers are
tools of last resort, in my view. Perhaps we mean different things by
"debugger".
[Similarly, writing Java code in Eclipse it was /months/ before I
found out how to use the debugger -- a colleague used it in front
of me -- and I still regularly don't use it. I do rely on being
able to get a backtrace, though, but you don't have to use the
debugger to get /those/.]


It must be a personal thing. For me the debugger is as crucual a part
as the editor : I would normally always step through the
debugger just to sniff out any issues with uninitialised stuff,
pointer run throughs etc. Its why IDEs put so much effort into the
debugger part these days.


I'd like there to /be/ a debugger, and for it to be decent, because
being a tool of last resort doesn't mean that it shouldn't /work/;
sometimes you end up against the wall. It's just that in the normal
course of developing my C software, I didn't have reason to use one.

Maybe there's an application area difference.

--
Chris "was stirred, now shaken" Dollin
RIP Andreas "G'Kar" Katsulas, May 1946 - February 2006
Feb 22 '06 #52
On 2006-02-22, Chris Dollin <ke**@hpl.hp.co m> wrote:
Developing code in a way that doesn't require using a debugger wouldn't
be encouraged? Really?

I suspect we have some fundamental disconnect somewhere. Debuggers are
tools of last resort, in my view. Perhaps we mean different things by
"debugger".


As I mentioned before a debugger is not just for finding bugs when
they are there. It is used as a vital TESTING tool.

We will agree to disagree : for me, when available, a debugger is an
indispensable aid to good productivity and ultimately bug free
code. It also enourages a coding style which facilitates debugger use
and, as a result, better maintainability by future generations. And
this I have some experience of.

To aim "not to use a debugger" is, for me, preposterous.
Feb 22 '06 #53

Richard G. Riley wrote:
On 2006-02-22, Chris Dollin <ke**@hpl.hp.co m> wrote:
Developing code in a way that doesn't require using a debugger wouldn't
be encouraged? Really?

I suspect we have some fundamental disconnect somewhere. Debuggers are
tools of last resort, in my view. Perhaps we mean different things by
"debugger".


As I mentioned before a debugger is not just for finding bugs when
they are there. It is used as a vital TESTING tool.


There are much better testing tools than a debugger.

Debuggers are not there to /find/ bugs. They are there to help you
/fix/ them once found (and that, more often than not, happens /outside/
the debugger).

--
BR, Vladimir

Feb 22 '06 #54
Richard G. Riley wrote:
On 2006-02-22, Chris Dollin <ke**@hpl.hp.co m> wrote:
Developing code in a way that doesn't require using a debugger wouldn't
be encouraged? Really?

I suspect we have some fundamental disconnect somewhere. Debuggers are
tools of last resort, in my view. Perhaps we mean different things by
"debugger".
As I mentioned before a debugger is not just for finding bugs when
they are there. It is used as a vital TESTING tool.


Ye gods and little fishes, a debugger is no more a testing tool than
a rainbow is a three-volume novel. You /must/ mean something different
by debugger than I do.
To aim "not to use a debugger" is, for me, preposterous.


Colour me gobsmacked.

--
Chris "was stirred, now shaken" Dollin
RIP Andreas "G'Kar" Katsulas, May 1946 - February 2006
Feb 22 '06 #55
In article <dt**********@m alatesta.hpl.hp .com>, Chris Dollin
<ke**@hpl.hp.co m> writes
Richard G. Riley wrote:
On 2006-02-22, Chris Dollin <ke**@hpl.hp.co m> wrote:
Developing code in a way that doesn't require using a debugger wouldn't
be encouraged? Really?

I suspect we have some fundamental disconnect somewhere. Debuggers are
tools of last resort, in my view. Perhaps we mean different things by
"debugger".


As I mentioned before a debugger is not just for finding bugs when
they are there. It is used as a vital TESTING tool.


Ye gods and little fishes, a debugger is no more a testing tool than
a rainbow is a three-volume novel. You /must/ mean something different
by debugger than I do.


You are wrong. There are several unit and system test systems that work
with an ICE or JTAG to test the system and software on the target
hardware.

On one project I did the all the unit test for a system using an ICE to
run the code on the hardware. the white box system test was also done
using an ICE on some parts only a BDM or JTAG is available not an ICE.

This sort of testing is virtually mandated on safety critical systems
after all how do you do MDSC code coverage without an ICE or debugger?
To aim "not to use a debugger" is, for me, preposterous.


Colour me gobsmacked.


You are.

However you would not

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys. org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Feb 22 '06 #56
Chris Hills wrote:
In article <dt**********@m alatesta.hpl.hp .com>, Chris Dollin
<ke**@hpl.hp.co m> writes
Richard G. Riley wrote:
On 2006-02-22, Chris Dollin <ke**@hpl.hp.co m> wrote:
Developing code in a way that doesn't require using a debugger wouldn't
be encouraged? Really?

I suspect we have some fundamental disconnect somewhere. Debuggers are
tools of last resort, in my view. Perhaps we mean different things by
"debugger".

As I mentioned before a debugger is not just for finding bugs when
they are there. It is used as a vital TESTING tool.


Ye gods and little fishes, a debugger is no more a testing tool than
a rainbow is a three-volume novel. You /must/ mean something different
by debugger than I do.


You are wrong. There are several unit and system test systems that work
with an ICE or JTAG to test the system and software on the target
hardware.


I think this may be the "something different". When I say "use the
debugger" I mean a human working interactively with a tool to locate
a point of failure in a system, by placing break/watch-points on
locations/triggers and looking with the eyes at the machine state.

What you describe sounds perfectly sensible - but I wouldn't describe
it as "using a debugger"; I think this is the disconnect.

[I don't know if I'd call the tools you mention "debuggers" , either, but
it's too late to know for sure whether I wouldn't have /before/ this
discussion.]

--
Chris "was stirred, now shaken" Dollin
RIP Andreas "G'Kar" Katsulas, May 1946 - February 2006
Feb 22 '06 #57

Chris Dollin wrote:
Chris Hills wrote:
In article <dt**********@m alatesta.hpl.hp .com>, Chris Dollin
<ke**@hpl.hp.co m> writes
Richard G. Riley wrote:

On 2006-02-22, Chris Dollin <ke**@hpl.hp.co m> wrote:
> Developing code in a way that doesn't require using a debugger wouldn't
> be encouraged? Really?
>
> I suspect we have some fundamental disconnect somewhere. Debuggers are
> tools of last resort, in my view. Perhaps we mean different things by
> "debugger".

As I mentioned before a debugger is not just for finding bugs when
they are there. It is used as a vital TESTING tool.

Ye gods and little fishes, a debugger is no more a testing tool than
a rainbow is a three-volume novel. You /must/ mean something different
by debugger than I do.


You are wrong. There are several unit and system test systems that work
with an ICE or JTAG to test the system and software on the target
hardware.


I think this may be the "something different". When I say "use the
debugger" I mean a human working interactively with a tool to locate
a point of failure in a system, by placing break/watch-points on
locations/triggers and looking with the eyes at the machine state.

What you describe sounds perfectly sensible - but I wouldn't describe
it as "using a debugger"; I think this is the disconnect.

[I don't know if I'd call the tools you mention "debuggers" , either, but
it's too late to know for sure whether I wouldn't have /before/ this
discussion.]


I think "ICE" is a giveaway. It stands for In Circuit Emulator (I know
you all know). The fact that some good tools (cf. Lauterbach) often
bundle them with their debuggers can lead to confusion. And yes, in
this combination they can be powerful, even irreplaceeable, testing
tools.

However, I'm afraid that's not what Richard meant earlier.

--
BR, Vladimir

Feb 22 '06 #58
On 2006-02-22, Vladimir S. Oka <no****@btopenw orld.com> wrote:

Richard G. Riley wrote:
On 2006-02-22, Chris Dollin <ke**@hpl.hp.co m> wrote:
> Developing code in a way that doesn't require using a debugger wouldn't
> be encouraged? Really?
>
> I suspect we have some fundamental disconnect somewhere. Debuggers are
> tools of last resort, in my view. Perhaps we mean different things by
> "debugger".


As I mentioned before a debugger is not just for finding bugs when
they are there. It is used as a vital TESTING tool.


There are much better testing tools than a debugger.

Debuggers are not there to /find/ bugs. They are there to help you
/fix/ them once found (and that, more often than not, happens /outside/
the debugger).


You have just lost all possible reason for being listened to. That is total
and utter rubbish. You are clearly not familiar with debuggers.

While many bugs can and are found outside of debuggers, many can only
be caught with HW breakpoints and clever watch expressions. This in
addition to using a debugger as a<testing tool by tweaking run time
valuesto test the robustness of certain routines.

--
Remove evomer to reply
Feb 22 '06 #59
On 2006-02-22, Chris Dollin <ke**@hpl.hp.co m> wrote:
Chris Hills wrote:
In article <dt**********@m alatesta.hpl.hp .com>, Chris Dollin
<ke**@hpl.hp.co m> writes
Richard G. Riley wrote:

On 2006-02-22, Chris Dollin <ke**@hpl.hp.co m> wrote:
> Developing code in a way that doesn't require using a debugger wouldn't
> be encouraged? Really?
>
> I suspect we have some fundamental disconnect somewhere. Debuggers are
> tools of last resort, in my view. Perhaps we mean different things by
> "debugger".

As I mentioned before a debugger is not just for finding bugs when
they are there. It is used as a vital TESTING tool.

Ye gods and little fishes, a debugger is no more a testing tool than
a rainbow is a three-volume novel. You /must/ mean something different
by debugger than I do.
You are wrong. There are several unit and system test systems that work
with an ICE or JTAG to test the system and software on the target
hardware.


I think this may be the "something different". When I say "use the
debugger" I mean a human working interactively with a tool to locate
a point of failure in a system, by placing break/watch-points on
locations/triggers and looking with the eyes at the machine state.


You are discussing rationally so lets stick with this. Everything you
have just said is exactly what I mean by using a debugger. A debugger
isnt only there to locate a point of failure although clearly that is
a major use. It can also be used, as I have repeatedly stated, to test
the system at run time. You can even connect to running processes in
most systems.

I *always* use a debugger to run through any meaningful critical
code. It enables me to cast an eye over memory, stacks, locals etc. It
is an added safety barrier beyond my own smug ability to write error
free code :)

What you describe sounds perfectly sensible - but I wouldn't describe
it as "using a debugger"; I think this is the disconnect.

[I don't know if I'd call the tools you mention "debuggers" , either, but
it's too late to know for sure whether I wouldn't have /before/ this
discussion.]


Debugger. Eclipse "debugger". gdb. All debuggers. All code development
tools. All very much used in any real SW development cycle.
--
Remove evomer to reply
Feb 22 '06 #60

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

Similar topics

22
2102
by: Stan | last post by:
Hey everyone, I've got a computer science class and we're working on C++. I am struggling with nested loops and have a really simple assignment, but I can't get it to run the loop. I need to run a loop that has someone guess at a number 5 times and if they get 45, it tells them how many guesses they needed. It also has to tell them if they leave the range of guesses from 0 to 100. I need help. Can somebody help me please!!!
4
2010
by: Rowan | last post by:
Hi there, it's me again. I am having trouble with a view again. I am trying to do a calculation, but there are some checks that need to be taken into consideration. Maybe a view is not the right way to deal with this. I don't know. This is the beginning of my query. SELECT coalesce(f.filenumber, i.filenumber) as filenumber, i.InvoiceNumber, i.InvoiceValue, il.lineid, MPF = .21 * (il.UnitCost * il.UnitQty + il.AddMMV - il.MinusMMV -...
26
6772
by: dagger | last post by:
Hi there. I'm using C under FreeBSD with the gcc compiler and am having a bit of trouble using the calloc and realloc calls. As an example the code snippet: #include <stdio.h> int main() { char *ptr;
4
5625
by: Angus Comber | last post by:
Hello I have received a lot of help on my little project here. Many thanks. I have a struct with a string and a long member. I have worked out how to qsort the struct on both members. I can do a bsearch on the long member (nKey) but I am struggling to do a search using the string member. The code I am running appears below. It doesn't crash or anything. It is just that when I do the last bsearch using "192.168.1.3" I SHOULD find...
5
4067
by: | last post by:
I am really struggling to conceptually understand classes in C# especially the use of the strange keywords 'static' 'void' and 'override'.... Is there a 'idiots' way of understanding these concepts broadly before even touching a line of code.... Thanks Jason
2
1281
by: mjeaves | last post by:
Hello there, Hope someone can help. I have data arriving in a table, a Cron job is triggered when the data arrives. ---- table_1 id (unique)
97
5589
by: Master Programmer | last post by:
An friend insider told me that VB is to be killled off within 18 months. I guess this makes sence now that C# is here. I believe it and am actualy surprised they ever even included it in VS 2003 in the first place. Anyone else heard about this development? The Master
0
1050
by: Steve | last post by:
I'm struggling to get proper runtime and designtime dpi values. In the forms .designer.vb I've added the following code after InitializeComponent() Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0F, 96.0F) Me.AutoScaleMode = Windows.Forms.AutoScaleMode.Dpi And in my code behind the form, I've added,
11
22896
by: briankind | last post by:
Hello i have these radio buttons and i wish to have the corresponding textboxes to be visible when the radiobutton is selected. any Help? snippets. thanks thanks in adv Bry
0
9933
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10734
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10836
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10407
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9567
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7114
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5982
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4606
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3230
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.