473,836 Members | 1,416 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 4750
Richard G. Riley wrote:
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'm sure you can. You don't make it clear in "It can also be used, as I
have repeatedly stated, to test the system at run time" whether you mean
manual or automated testing. Dinking around by hand at run-time with a
debugger would strike me as an approach of last resort. Doing so
/routinely/ strikes me as an act of madness - I mean, I'm fallible
enough already.

[This is different, as far as I can tell, from Chris Hill's description
of automated testing using ICEs etc.]
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 :)
Well, I don't know what you're doing; I've just never been in a situation
where this would be helpful. I'm under no illusions about my ability to
write error-free code, it's just that using a debugger doesn't give me
value for money.
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.


debuggers (and why is the Eclipse debugger awarded scare-quotes?) ...
All code development tools.
.... not (necessaily) debuggers: there's a difference here.
All very much used in any real SW development cycle.


There are other approaches than routine manual use of debuggers.

--
Chris "was stirred, now shaken" Dollin
RIP Andreas "G'Kar" Katsulas, May 1946 - February 2006
Feb 22 '06 #61
On 2006-02-22, Chris Dollin <ke**@hpl.hp.co m> wrote:
Richard G. Riley wrote:
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'm sure you can. You don't make it clear in "It can also be used, as I
have repeatedly stated, to test the system at run time" whether you mean
manual or automated testing. Dinking around by hand at run-time with a
debugger would strike me as an approach of last resort. Doing so


Connecting to external processes is more rare, I grant you.
/routinely/ strikes me as an act of madness - I mean, I'm fallible
enough already.

lets not get stuck on connecting to remote processes : lets keep it to
using the debugger to test and check new code.
[This is different, as far as I can tell, from Chris Hill's description
of automated testing using ICEs etc.]
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 :)
Well, I don't know what you're doing; I've just never been in a situation
where this would be helpful. I'm under no illusions about my ability to
write error-free code, it's just that using a debugger doesn't give me
value for money.


We must come from different schools of thought. I and every programmer
I have ever worked with routinely step through code alone or with a
colleague to check boundary conditions, memory initialisations etc. It
is a bedrock of any development I have done. Using break expressions
means I can put in wierd and wonderful parameters and have the
debugger break when a function is suddenly passed something it doesnt
know how to deal with. We are, after all, fallible.
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.


debuggers (and why is the Eclipse debugger awarded scare-quotes?) ...
All code development tools.


... not (necessaily) debuggers: there's a difference here.


Debugging is part of development in my world. maybe we are talking
nomenclature differences here?
All very much used in any real SW development cycle.


There are other approaches than routine manual use of debuggers.


Such as? An initial use of a debugger to monitor a programs progress
can show up lots of issues as well as facilitating routines boundary
tests. It just makes plain sense.
--
Remove evomer to reply
Feb 22 '06 #62
On Tue, 21 Feb 2006 19:09:44 +0000, Richard G. Riley wrote:
I wonder where the idea of a comma operator arose. Maybe dmr can
enlighten us. AFAICT its primary use is in the creation of obfuscative
macros.

It is very common in (of course) variable declarations and also
declarations and assignments in the initialising clause of for loops

e.g

for(i=0,j=2;che ck(i,j);i++,j++ );


I'd write

for (i = 0; check(i, i + 2); i++);

There are cases (though I can't think of any right now!) where the
relationship between control variables is too complex (or expensive) to
capture, but when you can, I think having one is clearer.

--
Ben.

Feb 22 '06 #63
"Richard G. Riley" wrote:
.... snip ...
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.


Yes, I can vaguely remember doing such things about 25 or 30 years
ago. I outgrew it. I find a sound design and functional breakdown
works much better.

--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell. org/google/>
Also see <http://www.safalra.com/special/googlegroupsrep ly/>
Feb 22 '06 #64

RG schrieb:
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).
[...]
What ticks me off is that
other kids are getting this stuff easily, while I am having a hard
time.


It is possible, that you have difficulties with loops because you think
functional, not imperative. In fact, there are (serious) programming
languages like for example Haskell, that don't have any loop syntax.
Someone who is used to "think in C" will probably have a hard time to
understand a Haskell program.
Fortunately, almost any loop can be written as a recursive function. So
if you understand recursion and functions and like them more than
loops, try it out.

Feb 22 '06 #65
In article <dt**********@m alatesta.hpl.hp .com>, Chris Dollin
<ke**@hpl.hp.co m> writes
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.


This is also a good use of a debugger.
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.]


It depends some are ICE. I tend to cal JTAG and BDM "Debuggers" as
opposed to ICE. At one time people refereed to JTAG as an ICE or
Emulator.
--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys. org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Feb 22 '06 #66
On 2006-02-22, CBFalconer <cb********@yah oo.com> wrote:
"Richard G. Riley" wrote:

... snip ...

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.


Yes, I can vaguely remember doing such things about 25 or 30 years
ago. I outgrew it. I find a sound design and functional breakdown
works much better.


Do you write standalone SW that only you maintain?

I find it incredulous that as a programmer, a debugger isnt a very
important tool on your list.

Noone is suggesting that good design and functionaly breakdown are not
important. What is indisputable though is that a debugger provides a
programmer with an easy, flexible way to perform run time checks and
manipulation of his code. ESPECIALLY when adding or modifying a legacy
system. Frequently you may need to call a poorly document external
function and need to bounds check it to be sure you can handle the
data and that it doesnt fall over with your "perfectly sound" input
data.

--
Remove evomer to reply
Feb 22 '06 #67
Richard G. Riley wrote:
We must come from different schools of thought. I and every programmer
I have ever worked with routinely step through code alone or with a
colleague to check boundary conditions, memory initialisations etc.


I and the programmers I work with do not. What you describe is a
inefficient procedure seems to me. For the cases you mention,
running a thorough regression suite together with tools that analyze
correctness of memory access seems more efficient. For example,
on the project I work on we have an automated run that runs our
(many hundreds) of regression tests under Valgrind and a separate
memory leak checker every weekend.

I regularly use a debugger for analyzing cores. I occasionally
use it for stepping through code to investigate a specific bug,
but I don't use it or need it for code development. We do have
lots of "printfs" (via our configurable logging facility) that is
generally all I need to debug problems. Which is actually more
useful, because while we can ask customers to turn up the
logging, we usually can't and don't want to ask to step through
stuff in the field on their machines.

-David

Feb 22 '06 #68
On 2006-02-22, David Resnick <ln********@gma il.com> wrote:
Richard G. Riley wrote:
We must come from different schools of thought. I and every programmer
I have ever worked with routinely step through code alone or with a
colleague to check boundary conditions, memory initialisations etc.
I and the programmers I work with do not. What you describe is a
inefficient procedure seems to me. For the cases you mention,
running a thorough regression suite together with tools that analyze
correctness of memory access seems more efficient. For example,


For certain large projects yes.
on the project I work on we have an automated run that runs our
(many hundreds) of regression tests under Valgrind and a separate
memory leak checker every weekend.
Again, very useful. And in no way am I suggesting that these
auotmation tools should not be used.

I regularly use a debugger for analyzing cores. I occasionally
use it for stepping through code to investigate a specific bug,
but I don't use it or need it for code development. We do have
lots of "printfs" (via our configurable logging facility) that is
generally all I need to debug problems. Which is actually more
Fine. but printfs dont allow you to tweak parameters, pointers etc to
check certain things at the point of execution. I find that a very
useful ability and it is, of course, why such facilities exist.
useful, because while we can ask customers to turn up the
logging, we usually can't and don't want to ask to step through
stuff in the field on their machines.
Logging is a different issue as was raised in an earlier post and
certainly has its place in analysing runtime errors or
inefficiencies. There is no argument from me on that.

-David

--
Remove evomer to reply
Feb 22 '06 #69
Richard G. Riley wrote:
On 2006-02-22, CBFalconer <cb********@yah oo.com> wrote:
"Richard G. Riley" wrote:

... snip ...

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.


Yes, I can vaguely remember doing such things about 25 or 30 years
ago. I outgrew it. I find a sound design and functional breakdown
works much better.


Do you write standalone SW that only you maintain?

I find it incredulous that as a programmer, a debugger isnt a very
important tool on your list.

Noone is suggesting that good design and functionaly breakdown are not
important. What is indisputable though is that a debugger provides a
programmer with an easy, flexible way to perform run time checks and
manipulation of his code. ESPECIALLY when adding or modifying a legacy
system. Frequently you may need to call a poorly document external
function and need to bounds check it to be sure you can handle the
data and that it doesnt fall over with your "perfectly sound" input
data.


"As a personal choice, we tend not to use debuggers beyond
getting a stack trace or the value of a variable or two. One
reason is that it is easy to get lostin detals of complicated
data structures and control flow; we find stepping through a
program less productive than thinking harder and adding
output statements and self-checking code at critical places."

Written by those idiots Brian Kernighan and Rob Pike, in the
ill-regarded "The Practice of Programming", section 5.1, Debuggers.
(yes, "idiots" and "ill-regarded" is sarcasm).

That doesn't mean you are entirely wrong. Heck, what do those
guys know that you don't? What it does suggest is that some
respected programmers think that Chuck's approach is perfectly
reasonable. It doesn't mean that you are wrong -- they point out
later in the section that debuggers can be of enormous value.
The perl saying that There's More Than One Way To Do It applies
to code development as well But don't be so sure you have
found the ONE TRUE WAY.

-David

Feb 22 '06 #70

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

Similar topics

22
2090
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
2006
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
6769
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
5621
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
4061
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
1277
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
5567
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
1047
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
22886
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
9813
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
9665
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10835
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10249
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...
1
7785
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5645
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5818
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4447
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
2
4007
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.