The program '[6096] lencod.exe' has exited with code 300 (0x12c).
what does this mean? is there an error? i have a variable named mbBits->mb_total. is the arrow a syntax of some sort or is it just part of the variable name. i'm debugging the code which i downloaded but when i put the variables in the watch window it says "undefined variable 'mbBits' or something like that.
I also used this code to generate a text file
void next_macroblock(Macroblock *currMB)
{
FILE * pFile;
pFile = fopen ("myfile.txt","a");
fprintf (pFile, " \t %d \t | \n",mbBits->mb_total);
fclose (pFile);
}
but it says that FILE is unidentified and it also tells me to save the code in Unicode Format. I already tried doing that but more errors come out. heeeeeelp
You will need to at least include <stdio.h> to get the references to FILE to compile.
The main() function also probably has a non-void return value. The value returned is what is displayed in your message. Include a return(0); in each possible path to ensure that the value is set to 0 (indicating, by convention, no error) in the program.
Related
I'm working through the book "C Programming Absolute Beginner's Guide to learn a little more about C so I can better understand what I need to do for an Arduino project. I'm using Xcode 12.4 on a Big Sur iMac because CodeBlocks, the IDE used in the book's examples, doesn't work on this computer.
In the chapter that covers scanf() when I run the sample program, Xcode returns (lldb) after my first input. Here's my simplified program that exhibits that return:
//
// main.c
// Chapter8ex1a
//
// Created by Kellidad on 3/25/21.
//
/* This program asks the user for some basic data and prints it on the screen to show
what was entered */
#include <stdio.h>
int main() {
// setup the variables that scanf will fill
char firstInitial;
char lastInitial;
printf("What letter does your first name begin with?\n");
scanf(" %c, &firstInitial");
printf("What letter does your last name begin with?\n");
scanf(" %c, &lastInitial");
printf("\nYour initials are %c.%c.", firstInitial, lastInitial);
return 0;
}
And here's what is displayed in the console:
What letter does your first name begin with?
L [followed by <Return>]
(lldb)
In addition, Xcode displays "Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)" at the first scanf() line.
Matt suggested it's a prompt waiting for something else, but if I repeat and enter another character I get this:
What letter does your first name begin with?
L <Enter>
(lldb) H <Enter>
error: 'H' is not a valid command.
(lldb)
Unfortunately, what I've found about (lldb) is meaningless to me. Can I make scanf() work in this example using Xcode or is there a better way for a beginner to accept characters from the keyboard?
Thanks!
The problem was the position of the " " in the scanf() - the function should read scanf(" %c", &firstInitial); not scanf(" %c, &firstInitial");
I have a simple .ahk file which reloads the currently running script any time I press Esc.
; reload-hotkey.ahk
Esc::Reload ; reload script with Esc
For some reason, importing this file causes global variables to stop working properly.
; test-file.ahk
#Include %A_ScriptDir%\reload-hotkey.ahk ; This line causes the problem
globalString := "Hello"
^q::
localString := "World"
MsgBox '%globalString% %localString' ; Output: ' World'
Return
If I remove my #include statement, the code works as expected.
; test-file-2.ahk
globalString := "Hello"
^q::
localString := "World"
MsgBox '%globalString% %localString%' ; Output: 'Hello World'
Return
This only happens if my included file includes a hotkey. If the function only includes methods or functions, my code will work as expected.
For reference, I am using AutoHotkey Unicode 32-bit 1.1.26.01.
Why would an #include statement cause global variables to not work properly?
Variable definitions must occur before any hotkey or hotstring definitions.
So put the variable definition above the include statement.
globalString := "Hello"
#Include %A_ScriptDir%\reload-hotkey.ahk ; This line causes the problem
For more information, see the Auto-execute Section in the Autohotkey documentation.
running the following code prints out the ifa_flags value for each interface. Running ifconfig immediately after will show different FLAGS values for each interface. Why is this? How can I get ifconfig's FLAGS value without parsing a shell command's output?
void printFlags(){
struct ifaddrs *addrs, *nextAddr;
getifaddrs(&addrs);
nextAddr = addrs;
while(nextAddr){
fprintf(stdout, "%s\' FLAGS: %u\n", nextAddr->ifa_name, nextAddr->ifa_flags);
nextAddr = nextAddr->ifa_next;
}
}
The reason they are different is because ifconfig decides to print the flags in hex format. Despite the Kernel passing this value around as an int or a short etc... Whatever... Simple way to see it: fprint("Flags: %x", flags);
System info: Windows 7, MSVS 2010
The following is a simple program, in which I am testing how Call Stack option in debug works
#include<stdio.h>
#include "stdafx.h"
int main()
{
printf("hello"); //breakpoint
}
When I debug the control hits the break point and the Call Stack is:
testapp.exe!main() Line 10 C++
testapp.exe!__tmainCRTStartup() Line 555 + 0x19 bytes C
testapp.exe!mainCRTStartup() Line 371 C
kernel32.dll!75e7ed6c()
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
ntdll.dll!77a537eb()
ntdll.dll!77a537be()
How do I interpret this result? Ad what is __tmainCRTStartup()?
Update
Just checked, the same output in Call Stack even if I am having .c file instead of .cpp file.
The call stack is used to figure out which line of code the debugger is currently at. The top one is the current location.
In your example the relevant line is testapp.exe!main() Line 10 C++ which means it's stopped at a function called main() which is at Line 10 in your file. Normally this contains the filename too.
Paste this code into your file and see if the call stack makes more sense for you when you break:
int main()
{
apple();
}
void apple()
{
banana();
}
void banana()
{
printf("hello"); //breakpoint
}
I need to pass an argument which will change every time from C program to a shell script.
int val=1234;
char buf[100];
sprintf(buf,"echo %d",val);
system("call.sh $buf");
call.sh::
#!/bin/sh
echo "welcome"
echo $*
echo "done"
output of C is::
welcome
done
I cant see the argument value which is 1234 in the script. Can anybody suggest me to get right value...
You can't pass a C variable as a shell variable. You need to build the whole command line in the string, and then pass it to system(...)
int val=1234;
char buf[100];
sprintf(buf, "call.sh %d", val);
system(buf);
You should use the setenv(), getenv() or putenv() functions (defined instdlib.h). Quoting the man:
The setenv() function adds the variable name to the environment with the value value, if name does not already exist. If name does exist in the environment, then its value is changed to value if overwrite is nonzero; if overwrite is zero, then the value of name is not changed. This function makes copies of the strings pointed to by name and value (by contrast with putenv(3)).
The prototype of the function is the following:
int setenv(const char *name, const char *value, int overwrite);